C++ programming language
 
Question:
Avatar

What do i do if i want to loop my program without goto when while doesn't work? I need it to be able to run a lot of code based off of whether the login was correct or not. I don't want to spaghetti-string all my code based off goto commands.

By alexz003 Asked Jul 15 2009 7:46PM
10
Pts
 
 
Rate Question
Answer Question Help someone!
Get the latest questions in C++ programming language
flag

Welcome to Answerbag, a community of people sharing what they know.
Sign up now to ask a question or help someone else by giving an answer!

signup now
 

First Answer

by TomP-C on Jul 17, 2009 at 5:38 pm Permalink

Avatar
You can use a FOR LOOP if for example you want to allow three login attempts before a screen comes up saying you've been locked out.

You can use a DO... WHILE loop or DO...UNTIL loop.

When you say "WHILE DOESN'T WORK" it sounds as though your real question ought to be what is wrong with this bit of code using a while loop.
0
Pts
 
 
Rate Answer
 
flag
Comments (be the first to comment)


Add an Answer

What do i do if i want to loop my program without goto when while doesn't work? I need it to be able to run a lot of code based off of whether the login was correct or not. I don't want to spaghetti-string all my code based off goto commands.

How to write a good answer
Your answer:

Display answer in fixed-width font (good for tables or text diagrams)

Answers must adhere to our Terms of Use

To create links, just type the address with no HTML code. Use the Preview button at the bottom to verify.

You can edit your answer at any time.

Add Video Add Iimage


Important: Answerbag cannot guarantee the accuracy of answers submitted by members, and we recommend that you use common sense when following any advice found here. Read full disclaimer.