while loops test the condition before every execution of the loop. Sometimes you want it to be tested after the loop.
This guarantees that the loop is run once before the condition is tested.
The above code prints out:
5
Then it tests $value which is now equal to 4 to see if it greater than 10. Since it is not the code within the loop is not run again
Next find out about do until loops
$value=5 do{ print "$value\n"; $value=$value-1; } while($value>10);
The above code prints out:
5
Then it tests $value which is now equal to 4 to see if it greater than 10. Since it is not the code within the loop is not run again
Next find out about do until loops
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: do while loops
by Anonymous Monk on May 24, 2000 at 05:04 UTC | |
by snafu (Chaplain) on Jun 15, 2001 at 23:59 UTC | |
by mrbbking (Hermit) on Dec 16, 2001 at 00:55 UTC | |
Re: do while loops
by Anonymous Monk on Oct 24, 2004 at 03:41 UTC | |
by Anonymous Monk on Jan 20, 2006 at 22:10 UTC | |
by Roy Johnson (Monsignor) on Jan 20, 2006 at 22:25 UTC | |
Re: do while loops
by sapnac (Beadle) on Dec 01, 2006 at 15:18 UTC | |
by f00li5h (Chaplain) on Dec 02, 2006 at 11:41 UTC | |
by Anonymous Monk on Jan 08, 2008 at 13:06 UTC | |
by f00li5h (Chaplain) on Jan 10, 2008 at 05:54 UTC |
Back to
Tutorials