nested-if





Nested if condition
The block of code following the else statement is executed as the condition present in the if statement is false. nested-if. Nested if statements means an if statement inside another if statement



syntax
if(condition-1)
{
    if (condition-2)
       {
        statement
       }
    else
       {
        statement block-2;
       }
}
else
 {
   statementblock-3;
 }



Flow chart






Example for nested if condition in [c-program]


#include< stdio.h>

void main()
{
  int a,b,c;

  printf("Enter three number");
  scanf("%d%d%d",&a,&b,&c);

    if(a>b)
      {
        if(a>c)
            printf("a=%d is big",a);
        else
            printf("c=%d is big",c);
       }

    else
      {
       if(b>c)
         printf("b=%d is big",b);
       else
        printf("c=%d is big",c);
     }
}


Youtube tutorial





Comments

Popular posts from this blog

operators in c program

switch-statement