C Programming

Nested if

If 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

Related Posts:

  • Accept Argument And Also Return : C Programming   C Programming                          Accept Argument And Also Return      … Read More
  • Control Statement : C Programming C Programming Control Statement The statement which control the flow of control is called control statement.    C Provides following types of control statement- 1. Selective Statement or Conditional Statement. … Read More
  • Constants in C : C Programming C Programming Constants in C A constant variable is such type of variable that's value can't be changed during execution of the program. Constants in C ConstantExample Decimal Constant10, 20, 450 etc. Real or Floating-p… Read More
  • C Operator : C Programming C Programming C Operators An operator is the symbol that take one or more than one operand and perform operation on it. Ex.   int a,b, c;      a=10,b=20;       c=a+b;&n… Read More
  • Simple if Statement : C Programming                  C Programming Simple if Statement The statement which executes on the basis of certain condition is called simple if statement… Read More