Conditional Statements (Nested If-Else Statement)
Conditional Statements (Nested If-Else Statement)
Objectives:
At the end of the module the students should be able to
1. Acquire knowledge about conditional statements in Turbo C programming.
2. Apply properly the nested if-else statement in creating programs in C.
Duration: 2 hrs.
a. Nested if else
The conditions are evaluated from top downward. As soon as a true condition is found, the
statement associated with it is executed and the rest of the ladder is bypassed. If none of the
conditions are true, the final else is executed. The final else often acts as a default condition;
that is, if all other conditional tests fail, the last else statement is performed. If the final else is
not present, then no action takes place if all other conditions are false.
Syntax
if (condition)
<statement 1>;
else if (condition) <statement 2>;
.
.
else <statement N>;