October 2011
Beginner to intermediate
1200 pages
35h 33m
English
if else if else ConstructionComputer programs, like life, might present you with a choice of more than two selections. You can extend the C++ if else statement to meet such a need. As you’ve seen, the else should be followed by a single statement, which can be a block. Because an if else statement itself is a single statement, it can follow an else:
if (ch == 'A') a_grade++; // alternative # 1else if (ch == 'B') // alternative # 2 b_grade++; // subalternative # 2a else soso++; // subalternative # 2b
If ch is not 'A', the program goes to the else. There, a second if else subdivides that alternative into two more choices. C++’s free formatting enables you to arrange these ...
Read now
Unlock full access