Looping switch statements

Hi Everyone, I've been coding out a type of case statement that would repeat itself. For example, the program will display a certain menu with a series of options. Once the user enters a number, a word is displayed... and i want the menu to come up again.

so far this is what i have...

int num;

cout << "Enter a choice between 1 and 3....... ";
cout << " 1. dog, 2. cat, 3. bird";
cin >> num;
cout << endl;

cout << "You have entered: " << num
<< endl;

switch(num)
{
case 0:
case 1:
cout << "dog ";
system ("pause");
break;
case 2:
cout << "cat ";
system ("pause");
break;
case 3:
cout << "bird " << endl;
system ("pause");
break;
}

return 0;
}

Now what I want to do is to repeat that, meaning after a number is entered, it will go back to the menu. What type of loop or command should I enter here?

Thanks.
i would recommend
do {...} while (...);

regards
to make your menu come up again use this:

1
2
3
4
5
6
7
char yesno;

do{

cout<<"Enter Y\y if you want to repeat it again: ";
cin>>yesno;
}while((yesno == 'Y') || (yesno == 'y'))
U can use

do {
----
----
}while(...);


or u can do by using a infinite for loop with break condition somewhere in the loop say for exiting!
Topic archived. No new replies allowed.