![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
A do While loop.. how to loop correctly? for a calc prog.Hello,
This program is suppsoe to display a menu and the user is suppose to select an option from the menu, then perform the operation...I have figured out how to get it to select the option and such, just cant get the program to continue to the menu selection after an operation was picked.... it should only quit when Q is selected, but it stays in Addition or subtraction till forever. How do I get it to go back to the menu selection?? Here is the code that I have: CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: A do While loop.. how to loop correctly? for a calc prog.Quote:
Well, look (yes, look) at the code. Here's what I see: Code:
Once you enter the loop, there is no new problem, no more menu, no more prompt, no more user input for the operation choice. Shouldn't your loop be more like the following, so that you can repeatedly create a new problem and print the menu and get user selection? CPP / C++ / C Code:
Regards, Dave Footnote: For the message indicating the correct answer, "your right" is grammatically incorrect. The contraction for "You are" is "You're" |
|
#3
|
|||
|
|||
Re: A do While loop.. how to loop correctly? for a calc prog.Hi! Your program keeps doing just one thing, because you only tell it to do one thing... As you have it, you never change the value of 'choice'. For it to do what you want it to do, you should insert the choice menu in the do..while loop. That way, it'll keep asking what to do, and doing it (untill you press 'Q')
OOPS.. someone was quicker than me... |
Recent GIDBlog
First week of IA training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Text-Based Roulette Game | mfm1983 | CPP / C++ Forum | 5 | 29-Nov-2006 12:20 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The