Download C++: A Beginner`s Guide, Second Edition

Transcript
cout << "Help on:\n"; cout << " 1. if\n"; cout << " 2. switch\n"; cout << "Choose
one: ";
3. Next, the program obtains the user’s selection, as shown here:
cin >> choice;
4. Once the selection has been obtained, the program uses this switch statement to display the syntax
for the selected statement:
Notice how the default clause catches invalid choices. For example, if the user enters 3, no case
constants will match, causing the default sequence to execute.
5. Here is the entire Help.cpp program listing:
12
C++ A Beginner’s Guide by Herbert Schildt