8.5. while() Loop

Synopsis: while (condition) loop_body

The while() loop executes the attached loop_body again and again as long as condition evaluates to true. The loop_body may be either a single statement or a block of statements.

Because condition is checked at the top of loop_body, it may not be executed at all if condition is false right from start.

Example 8.6. while() Loop

{
    integer a = 0;

    while (a < 10) a = a + 1;
 
    while (a >= 0)
    {
	y2milestone("Current a: %1", a);
	a = a - 1;
    }
}