Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 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.     cout << "Enter a number from 1 to 5: " << endl;
  14.     cin >> numb;
  15.  
  16.     while (numb != 0) {
  17.         cout << "Enter a number from 1 to 5: " << endl;
  18.         cin >> numb;
  19.    
  20.         if (numb >= 1 && numb <= 5) {
  21.             cout << "Your number is: " << numb << endl;
  22.         } else {
  23.             cout << "please enter a valid number" << endl;
  24.         }
  25.     }
  26.    
  27.     system("pause");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement