What is “The if...elseif...else
” Statement“?
The special Statement (if…elseif…else
) is used to combine multiple Statements (if…else
). The if-else-if-else
statement allows you to combine multiple If-else
statements, allowing the compiler to specify behaviors with more than two possible outcomes.
if (condition) {
code to be executed if this condition is true;
} else if (condition) {
code to be executed if first condition is false and this condition is true;
} else {
code to be executed if all conditions are false;
}
Example1:- If this condition is true!
Output:-
Example2:- If first condition is false and this condition is true!
Output:-
Example3:- If all conditions are false!
Output:-