C Programming
Nested ifIf any statement is executed on the basis of multiple if condition is called nested if.
if((condition)&&(condition)&&(condition))
{
//body to execute
}
else if((condition)&&(condition)&&(condition))
{
//body to execute
}
else if((condition)&&(condition)&&(condition))
{
//body to execute
}
else if((condition)&&(condition)&&(condition))
{
//body to execute
}
......
else
{
//body to execute
}
void main(){
int a,b,c;
printf("Enter three no.");
scanf("%d%d%d", &a,&b,&c);
if((a>b)&&(a>c))
{
printf("Greater no. is %d",a);
}
else if((b>a)&&(b>c))
{
printf("Greater no. is %d",b);
}
else
{
printf("Greater no. is %d", c);
}
getch();
}
Input: 20,15,30
Output: 30