Advertisement
ivanwidyan

Select From List of Options, Reprint List if Input's Invalid

Oct 17th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>  
  2. using namespace std;
  3.  
  4. int main() {
  5.     char input;
  6.     do {
  7.         cout << "Choose the menu list by its number: " << endl;
  8.         cout << "1. Play" << endl;
  9.         cout << "2. Option" << endl;
  10.         cout << "3. Exit" << endl;
  11.         cout << "Type your number: ";
  12.         cin >> input;
  13.         if (input == '1') {
  14.             cout << "You choose play" << endl;
  15.             return false;
  16.         }
  17.         else if (input == '2') {
  18.             cout << "You choose Option" << endl;
  19.             return false;
  20.         }
  21.         else if (input == '3') {
  22.             cout << "You choose Exit" << endl;
  23.             return false;
  24.         }
  25.         else {
  26.             cout << "Type the correct number" << endl;
  27.         }
  28.         cout << endl;
  29.     } while (true);    
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement