#include using namespace std; /* WHILE loop while(condition) command to be executed while the condition is satisfied */ int main() { int age; cout << "Please enter your age: "; cin >> age; while(cin.fail()) // it returns true if the input buffer has been given wrong data { cout << "You've entered the wrong data. Please enter your age again: "; cin.clear(); // hides the error flag cin.ignore(99999, '\n'); // empties the buffer cin >> age; } cout << "You are " << age << " years old. "; if(age > 17) cout << "You are an adult.\n"; else cout << "You are not an adult.\n"; return 0; }