// File name switchst.cpp // Examples using the switch statement #include using namespace std; int main() { int age; // Local variables declared char sex; cout << "Enter your age: "; cin >> age; cout << endl << "Enter your sex (M/F): "; cin >> sex; cout << endl; switch (age) { case 16: cout << "You can begin to drive" << endl; break; case 18: cout << "You can begin to vote" << endl; break; case 21: cout << "You may drink responsibly" << endl; break; } switch (sex) { case 'M': cout << "You are a male" << endl; break; case 'F': cout << "You are a female" << endl; break; default: cout << "Invalid sex code entered" << endl; } system("pause"); return 0; } // Sample Run Of The Above Program // Enter your age: 18 // // Enter your sex (M/F): M // // You can begin to vote // You are a male