if... else can be used in nested forms,when serious decisions are involved.
syntax:
if (condition)
statements to be executed if test expression is true;
else if(condition)
statements to be executed if test expressions 1 is true;
else if (condition)
. . .
else
statements to be executed if all test expressions are false;
program:
void main()
{
int a=40,b=20;
if (a == b)
{
printf("a is equal to b");
}
else if( a > b)
{
printf("a is greater than b");
}
else
{
printf("a is less than b");
}
}
output:
a is greater than b
0 comments:
Post a Comment