if..else if statement:
Syntax:
if(test_exepression1)
statement;
else if(test_expression2)
statement;
'
'
'
else if(test_expressionN)
statement;
This statement is used for handling a series of test expressions out of which any one test expression may get evaluate to TRUE and its corresponding statement will be executed. Otherwise the statement written under the else section will be executed.
Example : To check Biggest of 3 numbers
#include
main()
{
int a,b,c;
printf("\nEnter the value for a,b,c ");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("\n%d is biggest",a);
else if(b>c)
printf("\n%d is biggest ",b);
else
printf("\n%d is biggest",c);
}
Syntax:
if(test_exepression1)
statement;
else if(test_expression2)
statement;
'
'
'
else if(test_expressionN)
statement;
else
statement;This statement is used for handling a series of test expressions out of which any one test expression may get evaluate to TRUE and its corresponding statement will be executed. Otherwise the statement written under the else section will be executed.
Example : To check Biggest of 3 numbers
#include
main()
{
int a,b,c;
printf("\nEnter the value for a,b,c ");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("\n%d is biggest",a);
else if(b>c)
printf("\n%d is biggest ",b);
else
printf("\n%d is biggest",c);
}
Comments
Post a Comment