loops - C++ looping a menu -


I have the following code that compiles, but I will take the loop back to the original menu after selecting the user's choice So anyone else can be selected.

Any help would be greatly appreciated.

  #include & lt; Conio.h & gt; # Include & lt; Iostream & gt; using namespace std; Int main () {int likes; Cout & lt; & Lt; "Select your favorite soft drink: \ n"; Cout & lt; & Lt; "Pepsi - 1 \ n"; Cout & lt; & Lt; "Phantom 2 \ n"; Cout & lt; & Lt; "Fanta - 3 \ n"; CIN & gt; & Gt; the option; If (like == 1) {cout & lt; & Lt; "Good choice" & lt; & Lt; Endl; } And if (like == 2) {cout & lt; & Lt; "Not bad" & lt; & Lt; Endl; } And if (likes == 3) {cout & lt; & Lt; "Ew!" & Lt; & Lt; Endl; } Getch (); Return 0; }  

  #include & lt; Conio.h & gt; # Include & lt; Iostream & gt; using namespace std; Int main () {for (;;) {// & lt; - started loop int choice; Cout & lt; & Lt; "Select your favorite soft drink: \ n"; Cout & lt; & Lt; "Pepsi - 1 \ n"; Cout & lt; & Lt; "Phantom 2 \ n"; Cout & lt; & Lt; "Fanta - 3 \ n"; Cout & lt; & Lt; "Exit - 4 \ n"; // & lt; - 4 cin & gt; & Gt; Break the loop with option; If (like == 1) {cout & lt; & Lt; "Good choice" & lt; & Lt; Endl; } And if (like == 2) {cout & lt; & Lt; "Not bad" & lt; & Lt; Endl; } And if (likes == 3) {cout & lt; & Lt; "Ew!" & Lt; & Lt; Endl; } And if (like == 4) {break; }} // & lt; - Loop end here getch (); Return 0; }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -