When a series of decisions are required to solve a problem, then we have to use more than one if else statement in nested(if else inside another if) form. This type of structure helps to solve the complex problems in programming. General form of nested if else is shown below.
if(test_expression1){
if(test_expression2){
// if-block2
}
else{
// else-block2
}
// if-block1
}
else{
if(test_expression3){
// if block3
}
else{
// else-block3
}
// else-block1
}
There is no theoritical limit for the nesting level of if block. Following is the flowchart for two nested level.

Let’s see the problem to use nested if else.
You are required to read four integer numbers from the user then display the largest among them. The program to solve the problem looks like below.
// program to find the greatest among the four integer numbers
#include <stdio.h>
int main(){
int a, b, c, d;
printf("Enter four integer numbers:");
scanf("%d %d %d %d", &a, &b, &c, &d);
if(a > b){
if(a > c){
if (a > d){
printf("Largest is %d\n", a);
}
else{
printf("Largest is %d\n", d);
}
}
else{
if ( c > d){
printf("Largest is %d\n", c);
}
else{
printf("Largest is %d\n", d);
}
}
}
else{
if(b > c){
if(b > d){
printf("Largest is %d\n", b);
}
else{
printf("Largest is %d\n", d);
}
}
else{
if(c > d){
printf("Largest is %d\n", c);
}
else{
printf("Largest is %d\n", d);
}
}
}
return 0;
}
Sample Output is:
Enter four integer numbers:45
66
77
67
Largest is 77
Process returned 0 (0x0) execution time : 7.349 s
Press any key to continue.