Skip to content
Sign upLog in
← Back to Community

How to go back

Profile icon
softwarenginner

So If you take a look at my code in down I said Thank you for registering a bus. I mean I don't want to user stop the code and run it again. I just want a code that takes user back to the main menu. Every time when he click 1 or 2 just a button doesn't matter. Can you guys help me.

Thank you

Voters
Profile icon
DfgBen
Profile icon
AdaC06
Profile icon
Meesja
Profile icon
AliaSultan
Profile icon
softwarenginner
Comments
hotnewtop
Profile icon
Highwayman

Use a loop.

while(true){ // main menu code. }
Profile icon
softwarenginner

@Highwayman
Hey highwayman. I put your while. Code you send me and if you check my code again. My Code goes. But it goes forever. I don't if you are able to do changes, to my code. If you are able. Can you do it for me. And send me a picture or the code. If it is possible. Thank you.

Profile icon
Highwayman

@softwarenginner
here how about this. First I’m going to tell you how a while loop works, and then I am going to send you an online tutorial which I think you should take, because the answers to a lot of your problems seem like they could be answered by it.

While loops:
A loop is self explanatory I think, when you surround a block of code with a loop, it is repeated. A while loop is a type of loop that takes a single condition and checks that condition every time it repeats the given block of code. Here’s an example:

int x = 0; while(x != 1){ // is x equal to 1? No, do the code again. Yes, skip to end. cin >> x; } // go to top of loop.

Here’s the tutorial: http://www.cplusplus.com/doc/tutorial/

Profile icon
softwarenginner

Thank you I find the answer.