Home / Programs / Nested if-else
🚀 Programming Example

Nested if-else

👁 1,156 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()
{
 int age;
 
 printf("Please Enter Your Age Here:\n");
 scanf("%d",&age);
 
 if ( age < 18 )
 {
  printf("You are Minor.\n");
  printf("Not Eligible to Work");
 }
 else
 {
 
  if (age >= 18 && age <= 60 ) 
   { 
    printf("You are Eligible to Work \n"); 
    printf("Please fill in your details and apply\n"); 
   } 
  else 
   { 
    printf("You are too old to work as per the Government rules\n");
    printf("Please Collect your pension! \n");
   }
 }
 
 return 0;
}
                        

🖥 Program Output

Please Enter Your Age Here:
55
You are Eligible to Work
Please fill in your details and apply
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.