#include <iostream>
using namespace std;
void check_positive () {
cout << "Number given must be positive. Please try again." << endl;
}
int main() {
int pesos, interest, compound, year;
do {
cout << "How many pesos did you deposit? ";
cin >> pesos;
if (pesos <= 0) {
check_positive();
}
} while (pesos <= 0);
do {
cout << "What is the interest? ";
cin >> interest;
if (interest <= 0) {
check_positive();
}
} while (interest <= 0);
}
Whenever I run this code and enter "9+" as the input during the first loop, the first loop ends but then goes into an infinite loop immediately after the second loop starts. Why does this happen?