do loop ⇝
repeat loopPerl, Pascal, BASIC and C. The initial keyword may be "repeat" or "do" and the condition may be introduced with a "while" or "until" keyword. In constrast to a while loop, the "loop body" is executed once before the condition is tested. This is useful when the condition depends on the action of the loop body. In the following BASIC loop "Hello" is printed once despite the fact that the condition is false;
i = 2 repeat print "Hello" i = i+1 until i>0See also while loop and for loop.
Last updated: 1999-05-06