The if – else Statement:
The
if…else statement is an extension of the simple if statement. The general form
is :
if( test expression )
{
True
– block statement (s)
}
else
{
False
– block statement (s)
}
Statement
– x
If
the test expression is true, then the true – block statement (s) are executed;
otherwise, the false – block statement (s) are executed; In entire case, either
true - block or false – block will be executed, not both. In the both cases,
the control is transferred subsequently
to the statement – x;
For Example:
If ( a > 10 )
{
printf(“\n Number is
greater than 10”);
}
else
{
printf(“\n Number is
less than 10”);
}
printf(“\n Bye”);
Post a Comment