cs161ASpring2024/cin1.cpp

26 lines
453 B
C++
Raw Permalink Normal View History

2024-04-30 01:29:47 +00:00
#include <iostream>
using namespace std;
int main(){
int num1 = 0;
int num2 = 0;
string theRest;
cout << "Enter an integer" << endl;
cin >> num1;
if(!cin.fail()){
cout << "You entered: " << num1 << endl;
}
else {
cin.clear();
cin >> theRest;
cout << "You entered: " << theRest << endl;
}
/*
cout << "Enter another integer" << endl;
cin >> num2;
cout << "You also entered: " << num2 << endl;
*/
return 0;
}