SHARE
TWEET

Untitled

a guest Nov 12th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     cout << "Enter a number from 1 to 5: " << endl;
  14.     cin >> numb;
  15.  
  16.     while (numb != 0) {
  17.  
  18.         cout << "Enter a number from 1 to 5: " << endl;
  19.         cin >> numb;
  20.    
  21.         switch (numb)
  22.         {
  23.         case 1:
  24.             cout << "Your number is: 1" << endl;
  25.             break;
  26.         case 2:
  27.             cout << "Your number is: 2" << endl;
  28.             break;
  29.         case 3:
  30.             cout << "Your number is: 3" << endl;
  31.             break;
  32.         case 4:
  33.             cout << "Your number is: 4" << endl;
  34.             break;
  35.         case 5:
  36.             cout << "Your number is: 5" << endl;
  37.             break;
  38.         default: "Please enter a valid number";
  39.         }
  40.     }
  41.  
  42.    
  43.     system("pause");
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top