Computer Science, asked by alishasrivastava, 1 year ago

2 programming on nested if​

Answers

Answered by gurukulamdivya
1

Answer:

You have not mention the language in which you the program .

i am giving a C program where User can enter his age and we are going to store it in the variable age. If the age is less than 18 we are going to print 2 statements.

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

}

#include <stdio.h>

int main()

{

   int number1, number2;

   printf("Enter two integers: ");

   scanf("%d %d", &number1, &number2);

   if (number1 >= number2)

   {

     if (number1 == number2)  

     {

       printf("Result: %d = %d",number1,number2);

     }

     else  

     {

       printf("Result: %d > %d", number1, number2);

     }

   }

   else

   {

       printf("Result: %d < %d",number1, number2);

   }

    return 0;

}


alishasrivastava: bt in java programming
Similar questions