Home / Programs / Nested if
🚀 Programming Example

Nested if

👁 1,288 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

💻 Program Code

#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;
}
                        

🖥 Program Output

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 . . .
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.