part may be associated with a particular
if
construct.
Let us now see the if-else-if control construct.
The else-if control construct follows the if control construct to allow
multiple decision
making.
Syntax
if (boolExpr1)
{
Stml1;
}
else
if (boolExpr2)
{
Stml2;
}
else
if (boolExpr3)
{
Stml3;
}
………….
else if (boolExprN-1)
{
StmlN-1;
}
else {
StmlN;
}
Herein, if any
boolExpr
returns a true value, the
Stmt
associated with that
if
is executed and then
the next statement to the whole
else-if
construct is executed. If no expression returns a true value, the
last
else
part is executed. If there is no instruction needed for the last
else
part, then it can be omitted
or it can be used for displaying the error messages due to invalid conditions.
Do'stlaringiz bilan baham: |