patrick66
Hello All,
When I key in 'r' for int num, the value for num is something like
-895784932. This cause the subsequent cin >> choice to be ignored by the program. If I key in a small negative, say -5 then cin >> choice (char) is executed. How do I amend the code so that cin >> choice is executed for any input for num? What was the problem for the current failure?
Thanks.
The code segment:
cout << "Enter a positive number " << endl;
cin >> num;
while (num <= 0 && quit == false) {
fflush(stdin);
system("CLS");
cout << "The number you entered is not positive. Reentered(Y/N)?\n";
cin >> choice;
When I key in 'r' for int num, the value for num is something like
-895784932. This cause the subsequent cin >> choice to be ignored by the program. If I key in a small negative, say -5 then cin >> choice (char) is executed. How do I amend the code so that cin >> choice is executed for any input for num? What was the problem for the current failure?
Thanks.
The code segment:
cout << "Enter a positive number " << endl;
cin >> num;
while (num <= 0 && quit == false) {
fflush(stdin);
system("CLS");
cout << "The number you entered is not positive. Reentered(Y/N)?\n";
cin >> choice;