Nested if and Nested if else in C
Notes:
Nested if and if-else statements in C programming language :
- If required we can put an if statement inside another if or if else statement or we can put an if else statement inside another if or if else statement; which is called as nesting of if or if else statements.
Ex: Program to find the largest of 3 integer numbers
#include <stdio.h>
int main()
{
int a=20, b=10, c=30;
if(a > b)
{
if(a > c)
{
printf("a is largest\n");
}
else
{
printf("c is largest\n");
}
}
else if(b > c)
{
printf("b is largest\n");
}
else
{
printf("c is largest\n");
}
return 0;
}