#include <iostream>
#include <limits>
using namespace std;
main () {
int x, y;
// <-- NO READ HERE!
do {
cout << "Enter a number: ";
if (cin >> x) break;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
while (true);
// same as above, for y ...
}