Nesting of if…else statements:
When
a series of decisions are involved, we may have use more than one if…else
statement in nested form as shown:-
If
the condition – 1 is false, the statement – 3 will be executed; otherwise it
continues to perform the second test. If the condition – 2 is true, the
statement -1 will be executed; otherwise the statement – 2 will be executed and
then the control is transfer to the statement – x;
Flowchart:
For Example:
If
( a> b)
{
If ( a > c )
{
printf ( “\n A= %d is
greatest “, a);
}
else
{
printf (“\n C=%d is
greatest”,c);
}
}
Else
{
If( b> c)
{
printf (“\n B=%d is
greatest “,b);
}
Else
printf (“\n C=%d is
greatest”,c);
}
}
Post a Comment