elseif Ladder
else–if Ladder
Explanation
The else–if ladder is used when multiple conditions need to be checked one by one.
The first condition that evaluates to true is executed.
Syntax
if (condition1) {
}
else if (condition2) {
}
else {
}Real life Situation:
Student marks decide the grade.
Program
c
1#include <stdio.h>
2
3int main() {
4 int marks = 75;
5
6 if (marks >= 90)
7 printf("Grade A");
8 else if (marks >= 60)
9 printf("Grade B");
10 else
11 printf("Grade C");
12
13 return 0;
14}