C++ Else If
C++ Else If Statement Explanation
if (condition1) {
// code block 1
} else if (condition2) {
// code block 2
} else {
// code block 3
}
- The
if
statement checkscondition1
, and if it's true,code block 1
is executed. - If
condition1
is false, theelse if
statement checkscondition2
, and if it's true,code block 2
is executed. - If both
condition1
andcondition2
are false,code block 3
is executed.