Quote:
Originally Posted by angelcd
my problem is, this program comes back from the start whenever the output comes out
ex :
pls press letters from the choices below
1. i 2. m 3. e-exit";
i
inches
after that it repeats again, i want it to continue the program until i enter "e" for exit
What you need is a while loop, like everyone here has been saying. However, I think the others have misinterpreted what you're asking, so just to clarify: you want a program that will basically present a menu:
Press i for inches, m for meters, or e for exit
that will continue being displayed and calculations performed UNTIL the user hits e for exit.
If so, you can have the while loop controlled by the following condition:
You will have to have ch defined (as a character variable) outside of the loop. Also, you will have to ask the user for initial input. Inside the loop, you can immediately start with your calculations (i.e. if ch is i, print inches, or if ch is m, print meters), and do whatever you need to. The final statements in the loop, though, must be the menu and a prompt for user input. This loop will continue executing until the user enters 'e', at which point the loop condition will be false, and the loop will be skipped.
What the other repliers have addressed is a program that continues asking the user for input - as long as that input is bad (not i or m), or the input is e, they are still prompted - when i or m is entered, the program will display inches or meters accordingly and exit.