Nested if-block in C Language

This C Logical Programs explains: “Nested if-block in C Language” post provides the syntax, flow chart and example C Logical Programs of nested if-block in C Language.


 

Nested If-block :

  • Defining if block inside another if block is called Nested if block.
  • Nested if block is used to execute one block of statements depends on another block.

 

 

Biggest of 3 numbers using Nested if statement :

  • Defining if block inside another if block is called nested if.
  • Using nested-if blocks, we can set dependencies of conditions.
  • for example if outer block condition is true then only it checks inner block condition

    #include<stdio.h>
    void main()
    {
        int a,b,c;
        printf(“Enter 3 integers : “);
        scanf(“%d%d%d”, &a , &b , &c);
        if(a>b)
        {
            if(a>c)
                printf(“a is big”);
            else
                printf(“c is big”);
        }
        else
            if(b>c)
                printf(“b is big”);
            else
                printf(“c is big”);
    }
Share this