fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i = -1;
  8. cin >> i;
  9. while (i < 1 || i > 3)
  10. {
  11. cout << "you should provide a number between 1 & 3\n";
  12. cout << "i is currently " << i << "\n";
  13. cin.clear();
  14. cin.ignore(1000, '\n');
  15. cin >> i;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0s 2856KB
stdin
-2
hello
test
big4
3
2
stdout
you should provide a number between 1 & 3
i is currently -2
you should provide a number between 1 & 3
i is currently 0
you should provide a number between 1 & 3
i is currently 0
you should provide a number between 1 & 3
i is currently 0