#include <iostream> using namespace std; int main(){ int i = -1; cin >> i; while (i < 1 || i > 3) { cout << "you should provide a number between 1 & 3\n"; cout << "i is currently " << i << "\n"; cin.clear(); cin.ignore(1000, '\n'); cin >> i; } return 0;}
-2 hello test big4 3 2
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
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!