#include #include #include using namespace std ; int main() { int x1 = 0 ; /* cout << "Enter x1 value." ; cin >> x1 ; cout << x1 << endl ; while(1) { if(cin.fail()) { //clears the error flag cin.clear() ; //Ignore anything else in the buffer cin.ignore( numeric_limits::max() , '\n' ); cout<< "You have entered wrong input."<< endl; cin >> x1 ; } else break ; } cout << "x1:" << x1 << endl ; */ //Another way .. Does not work cout << numeric_limits::max() << endl ; x1 = numeric_limits::max() ; cout << "x1:" << x1 << endl ; while ( x1 == numeric_limits::max() ) { cout << "Enter x1 value." ; cin >> x1 ; //x1 is 0 at this point cout << x1 << endl ; } //while return 0; }