Asking the user if they would like to continue

Hi!

I'm making a simple calculator, and was able to create the calculator itself by using a switch statement.

So my question is, how exactly do i ask the user if they would like to continue(after it runs the first time), and if they say yes it brings back the menu of the calculator, and if they say no the program terminates? Hopefully this makes sense, would appreciate any help!

Last edited on
1
2
3
4
5
6
7
8
9
char userChoice;
do {
.............
<All of your main function code here>
.....................

cout << "Would you like to use the calculator again? (Y or N): ";
cin >> userChoice;
} while (userChoice == 'y' || userChoice =='Y')
Last edited on
Topic archived. No new replies allowed.