/* A simple switch statement example */ #include using namespace std; int main() { int selection; // Prompt the user for a selection: cout << "Enter:" << endl << "1 for a foo" << endl << "2 for a bar" << endl << "3 for a baz" << endl << "> "; cin >> selection; // Give the user what they asked for: switch (selection) { case 1: cout << "You entered 1." << endl; cout << "A foo on all your houses!" << endl; break; case 2: cout << "You entered 2." << endl; cout << "A bar on all your houses!" << endl; break; case 3: cout << "You entered 3." << endl; cout << "A baz on all your houses!" << endl; break; default: cout << "You did not enter 1, 2, or 3." << endl; } return 0; }