// Native_Switch.cpp : Defines the entry point for the console application. /* ________________________________________________ Learning C++: Lesson 4 Making Decisions With Switch Ron Kessler Created 5/29/2016 Native Version This little program shows how to use Switch instead of if statements to make decisions. Users make a choice and we tell them what they selected. Run with CTL-F5 _________________________________________________ */ #include "stdafx.h" #include using namespace std; int main () { int input; cout << "1. Play game\n"; cout << "2. Load game\n"; cout << "3. Play multiplayer\n"; cout << "4. Exit\n"; cout << "Selection: "; cin >> input; switch (input) { case 1: // Note the colon after each case, not a semicolon cout << "You selected : Play game\n"; break; case 2: cout << "You selected : Load game\n"; break; case 3: cout << "You selected : Play multiplayer\n"; break; case 4: cout << "Thank you for playing!\n"; break; default: // Note the colon for default, not a semicolon cout << "Error, bad input, quitting\n"; break; } }