27 lines
521 B
C++
27 lines
521 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include <stdexcept>
|
|
using namespace std;
|
|
|
|
int readInt(){
|
|
int ourInput;
|
|
|
|
cout << "Enter a whole number, only." << endl;
|
|
cin >> ourInput;
|
|
while(cin.fail() || cin.peek() == '.'){
|
|
cout << "Error: enter a whole number" << endl;
|
|
cin.clear();
|
|
cin.ignore(256,'\n');
|
|
cin >> ourInput;
|
|
}
|
|
return ourInput;
|
|
}
|
|
|
|
|
|
int main() {
|
|
int myInt1 = readInt();
|
|
int myInt2 = readInt();
|
|
cout << "Our numbers, added together, are... " << myInt1 + myInt2 << endl;
|
|
return 0;
|
|
}
|