Im new to programing in a whole and I was wondering how I could loop my while loop. I'm making a calculator and i've gotten to a part where I have the program ask whether or not the user wants to end the program, if the user answers "Yes" the program will end; however I have noticed that if the user answers "No" the program will just keep on working and not ask the question again. Is there a way where I can have it ask the question again?
while (response != "Yes" && response != "No") {
cout << "Would you like to end the program? Yes or No" << endl;
cin >> response;
if (response == "Yes") {
calculator_running = false;
} else if (response == "No") {
calculator_running = true;
} else {
cout << "Please choose a valid response" << endl;
}
}
calculator_runningto. This question is missing a minimal reproducible example. The answer will depend on what the rest of your program is doing with thatcalculator_runningvariable.