How can I create a DO WHILE LOOP MENU in C++?
OMG
Last edited on
- I would do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int choice;
do
{
// put your menu here, i assume you know how to do this
// put your prompts here as well
cin>>choice;
}
while (choice!=3)
|
Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
using namespace std;
void printMenu();
void enterName();
void enterNumber();
int main()
{
int menuChoice;
while(true)
{
printMenu();
cin >> menuChoice;
if (menuChoice == 1) enterName();
if (menuChoice == 2) enterNumber();
if (menuChoice == 3) break;
}
}
void printMenu()
{
cout << "MENU\n"
"[1] Enter a name\n"
"[2] Enter a number\n"
"[3] Exit program\n";
}
void enterName()
{
//get input
//print out input
}
void enterNumber()
{
//get input
//print out input
}
|
Topic archived. No new replies allowed.