Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. // Switch
  2. // Oscar Neal 31/10/19
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int numb;
  10.  
  11.     cout << "Press 0 to exit program" << endl << endl;
  12.  
  13.     while (numb != 0) {
  14.  
  15.         cout << "Enter a number from 1 to 5: " << endl;
  16.         cin >> numb;
  17.    
  18.         switch (numb)
  19.         {
  20.         case 1:
  21.             cout << "Your number is: 1" << endl;
  22.             break;
  23.         case 2:
  24.             cout << "Your number is: 2" << endl;
  25.             break;
  26.         case 3:
  27.             cout << "Your number is: 3" << endl;
  28.             break;
  29.         case 4:
  30.             cout << "Your number is: 4" << endl;
  31.             break;
  32.         case 5:
  33.             cout << "Your number is: 5" << endl;
  34.             break;
  35.         default: "Please enter a valid number";
  36.         }
  37.     }
  38.  
  39.    
  40.     system("pause");
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement