Computer Science, asked by simpl3737, 1 year ago

Can someone write the syntax of Nested if.... else Statement

Answers

Answered by Anchalsinghrajput
2
if ( test condition-1)
if ( test condition-2)
statement 1
else
statement 2
else
if ( test condition 3)
statement 3
else
statement 4
Answered by siddhartharao77
4

Syntax of Nested if..else:

if(condition is true)

{

    if(condition is true)

    {

   statement;

    }

   else

   {

   statement;

    }

}

else

{

statement;

}


Sample Program to calculate maximum of three numbers:

int a,b,c;

if(a > b)

{

     if (a > c)

     {

    printf("a is highest");

    }

   else

   {

   printf("c is highest");

   }

}

else

{

 if(b > c)

 {

 printf("b is highest");

 }

 else

 {

 printf("c is highest");

}



Hope it helps!

Similar questions