#include #include using namespace std; int main() { int x; cout << \"5 + 4 = \"; while(!(cin >> x)){
try this:
std::string input; std::cin >> input; if ( std::all_of(input.begin(), input.end(), std::isdigit) ) { //input is integer }
Refer this :
C++ Fix for checking if input is an integer