double age = 0;
int empAge;
cout << "Please enter your age in integers: ";
cin >> age;
// Input validation for age. To prevent input with a decimal number eg 5.6, 7.8, 90.9, etc
while(cin.fail() || ((int)age != (double)age)){
cout << "\nThat is not a valid option, please try again. ";
cin >> age;
if(cin.fail() || (int)age != double(age)){
cin.clear();
string not_an_int;
cin >> not_an_int;
}
cout << "That is not a valid option, please try again. ";
cin >> age;
}
// Assigns the data in variable of double type age to the variable of int type empAge
age = empAge;
What I need to get done ? Ask user to enter a integer digit only. If not an integer give error "That is not a valid option, please try again" and ask user to enter again.
Attached is also an image showing errors my code gives with the inputs used.

cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');right aftercin.clear()instead ofstring not_an_intetc.int tmp_age; cin >> tmp_age; ... // check for input fails ... double age = tmp_age;, which would make the last assignment (or comment) to have sense.