if-else-if Ladder:
A common programming construct is the if-else-if ladder, sometimes called the it- else-if staircase because of its appearance.
Syntax:
if(Expression-1)
statement-1;
else if(Expression-2)
statement-2;
else if(Expression-3)
statement-3;
- - - - - - -
- - - - - - -
else if(Expression-N)
statement-N;
else
statement-F;
The expressions are evaluated from the top downward .
As soon as a true expression is found, the statement associated with it is executed and the rest of the ladder is bypassed .
If none of expression are true, the final else is executed.
No comments:
Post a Comment