Software & Finance

Turbo C - Nested IF Statement

Here is an example for nested if statement in C Programming Language. Nested if means, an simple if statement occurs with in another if statement.


if statement evaluates the condition inside the paranthesis and if it is true, then it executes one line followed by if statement or the sequence of steps bound of { }.


if statement can be combined with else part which is explained in if else statement.


Nested if statement is explained with finding the biggest of 3 numbers example given below.


Source Code

#include <stdio.h>


void main()


   int a,b,c;

   int biggest;


   printf("Enter 1st Number: ");

   scanf("%d", &a);

   printf("Enter 2nd Number: ");

   scanf("%d", &b);

   printf("Enter 3rd Number: ");

   scanf("%d", &c);


   if(a > b)


      if(a > c)

         biggest = a;


         biggest = c;




      if(b > c)

         biggest = b;


         biggest = c;


   printf("Biggest of 3 numbers is: %d\n", biggest);




Enter a Number: -100

-100 is a negative number


Enter a Number: 55

55 is a positive number