Next: for loop Up: Decisions Previous: switch

while loop

Used to loop while an expression is true, commonly when iterating a number of times which is not fixed or known in advance. The syntax is:

   while (expression)
      statement

Note that the expression is tested first: the statement will not be executed at all if the expression is initially false. Sooner or later the statement must change the value of the expression or the while will loop forever.



Next: for loop Up: Decisions Previous: switch


maspjw@
Tue Sep 27 15:29:34 BST 1994