18 lines
378 B
C++
18 lines
378 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main(){
|
|
int num;
|
|
cout << "Enter a whole number: ";
|
|
cin >> num;
|
|
while(cin.fail() || cin.peek() == '.'){
|
|
cout << "Whoops. Enter a whole number: ";
|
|
cin.clear();
|
|
cin.ignore(256,'\n');
|
|
//cout << "Next char is: " << cin.peek() << endl;
|
|
cin >> num;
|
|
}
|
|
cout << "You entered: " << num << endl;
|
|
|
|
return 0;
|
|
} |