Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Explain the logic behind... (http://www.alice.org/community/showthread.php?t=7353)

fallout87 10-07-2011 08:35 AM

Explain the logic behind...
 
Could someone please explain the logic behind this:

[B]While[/B] count.variable <= value.variable
count.variable set value to (count.variable +1)
(blahblahblah) method

Count.variable is set to 1 btw.

TauTrumpsPi 10-07-2011 08:03 PM

That is called a count controlled while loop. Basically, it is a loop statement

It will execute the method the value of the value.variable times

So, look at it like this

Counter = 1
Flag = 3

While Counter <= Flag
count.variable set value to (Counter + 1)
(blahblahblah) method


So, the (blah) method will execute until the counter exceeds the Flag, in which it will stop. This is usually only useful in languages that don't have loop statements

fallout87 10-13-2011 02:10 PM

[QUOTE=TauTrumpsPi;42234]That is called a count controlled while loop. Basically, it is a loop statement

It will execute the method the value of the value.variable times

So, look at it like this

Counter = 1
Flag = 3

While Counter <= Flag
count.variable set value to (Counter + 1)
(blahblahblah) method


So, the (blah) method will execute until the counter exceeds the Flag, in which it will stop. This is usually only useful in languages that don't have loop statements[/QUOTE]


Thanks for the info!

That helped a lot : )

They are useful when an assessment says no "for loops" as well. lol

TauTrumpsPi 10-14-2011 02:38 PM

Yeah, that too, "for loops" usually take less time, but this does have it's uses. What language are you using, C, maybe?


All times are GMT -5. The time now is 04:56 PM.

Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.