English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i'm doing a source code on the game mastermind and im having trouble on loops! need help! ex:
loop
if (blah blah)
(i want to loop back up)
else
(blah blah)
again?
(loop back up again)
any other way of doing this???

2007-01-17 23:47:56 · 4 answers · asked by Sammy Baby 1 in Computers & Internet Programming & Design

4 answers

use a "do while" loop

pseudocode
BOOL End = 0;

do
{
if (blah blah)
{
//your code
}
else
{
do again?
if (no)
End = 1;
}
while (End == 0);

2007-01-18 01:12:04 · answer #1 · answered by justme 7 · 0 1

What exactly is the question? It's not exactly clear the way you state it, but if you want a loop to repeatedly return to an if check and then do something and end or do something else, then enclosing everything else in an else should be sufficient....

2007-01-18 07:53:55 · answer #2 · answered by ‫‬‭‮‪‫‬‭‮yelxeH 5 · 0 1

It looks like you want:

while (condition)
{
if (shouldDoThis)
{
doThis;
}
}

Another statement you need to look into is the 'continue' statement, it causes a loop to iterate and restart. Check your help manual for more info.

2007-01-18 09:34:09 · answer #3 · answered by Pfo 7 · 0 1

do it in different functions. like

1st function to check for 1st postion
2nd function to check for 2nd postion and so on.

2007-01-18 08:41:07 · answer #4 · answered by fang 4 · 0 1

fedest.com, questions and answers