Allow the user to input two integers. Variables, Num1 and Num2 (Num1 must be less than Num2, values must be a positive number) (use loop); create a user-defined function to validate the users input.
using std::cin;
using std::cout;
void user_input() {
int first = 0, second = 0;
bool good_input = false;
while (!good_input) {
cout << "Plese input two variables:\t";
cin >> first >> second;
if (first < second && first > 0 && second > 0) {
good_input = true;
cout << "Thank you!\n";
} else {
cout << "Please try again\n";
}
}
}
Comments
Leave a comment