5.3) If Statement: Multiple Branches
Example
if (x < 0) { cout << "x is negative" << endl; exit(1); } else if (x == 0) { // Handle special case where x is zero } else { // Do calculation with x here }
Key Points
if
clause can be followed byelse if
clauses, each of which must have a testelse
clause is optional but, if used, must come at the end