The else-if Ladder
🟢 Beginner
📖 Definition
An else-if ladder tests multiple conditions sequentially from top to bottom. As soon as a condition evaluates to true, its block is executed and the remainder of the ladder is skipped.
💡 Code Example
#include <iostream>
int main() {
int marks = 85;
if (marks >= 90) {
std::cout << "Grade A+\n";
} else if (marks >= 80) {
std::cout << "Grade A\n";
} else {
std::cout << "Grade B\n";
}
return 0;
}