...

View Full Version : Loops



Peetree1201
10-22-2008, 12:02 AM
Okay, so I've been taking computer programming for about 9 weeks now, and I love it! But does anyone have any tips for completing do while loops?

ghell
10-24-2008, 12:41 PM
What do you mean by "completing"?

A while loop and a for loop are just different ways of writing the same thing.

I'm going to give examples in C because you have not specified a language and many languages share C syntax.


for(a; b; c)
{
d;
}


is about the same as

a;
while(b)
{
d;
c;
}if that helps.


a;
do
{
d;
c;
}
while(b);is similar but "b" only gets evaluated after one pass, so it is guaranteed to run once.

You can also use "continue" and "break" to either stop the current pass of the loop and continue on to the next pass of the loop or break out of the loop entirely, respectively.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum