Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int InputInt(int lowestVal, int highestVal)
- {
- int input;
- cin >> input;
- while(input < lowestVal || input > highestVal)
- {
- cout << "Wrong input, make sure it is between " << lowestVal << " and " << highestVal << ":";
- cin >> input;
- }
- return input;
- }
- int main()
- {
- int num1, num2;
- cout << "Input 2 numbers to add between 1 and 10: ";
- num1 = InputInt(1, 10);
- num2 = InputInt(1,10);
- cout << "Result is: " << num1+num2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement