3.if-Else Ladder
3.if-Else Ladder
The if-else-if ladder statement executes one condition from multiple statements.
Syntax:
1. if(condition1)
2. {
3. //code to be executed if condition1 is true
4. }
5. else if(condition2)
6. {
7. //code to be executed if condition2 is true
8. }
9. else if(condition3)
10. {
11. //code to be executed if condition3 is true
12. }
13. ...
14. lse
15. {
16. //code to be executed if all the conditions are false
17. }
Example:
Output:
C grade
Program to check POSITIVE, NEGATIVE or ZERO:
Output:
NEGATIVE