Mega Code Archive

 
Categories / C++ Tutorial / Operators Statements
 

Char navigation based on switch

#include <iostream>  using namespace std;    int main() {    char choice;      cout << "Help on:\n";    cout << "  1. if\n";    cout << "  2. switch\n";    cout << "Choose one: ";    cin >> choice;      cout << "\n";       switch(choice) {      case '1':        cout << "The if:\n\n";        break;      case '2':        cout << "The switch:\n\n";        break;      default:        cout << "Selection not found.\n";    }      return 0;  } Help on: 1. if 2. switch Choose one: 1 The if: