Nested if in c programming langauge
In this example of c program you will how to use nested if in c programming Language.
In this example of c program you will how to use nested if in c programming Language.
#include"stdio.h"
int main () {
/* local variable definition */
int a = 200;
int b = 300;
/* check the boolean condition */
if( a == 200 ) {
/* if condition is true then check the following */
if( b == 300 ) {
/* if condition is true then print the following */
printf("Value of a is 100 and b is 200\n" );
}
}
printf("Exact value of a is : %d\n", a );
printf("Exact value of b is : %d\n", b );
return 0;
}
Value of a is 100 and b is 200
Exact value of a is : 200
Exact value of b is : 300
Press any key to continue . . .
In this example of c program you have learned that, how to use nested if in c programming Language.
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.