while while Statementwhile(expression)
statement;
The while statement executes the statements in the body as long as
expression is TRUE (not 0). The expression is tested at the top of
the loop before the body is executed. If the expression tests false
initially, the body of the loop is never executed. When the
expression tests false control is passed to the next statement
following the loop. The while loop may also be terminated by a
break, goto or return statement.
Note: The parentheses around expression are required.
The while loop may not be executed at all whereas the
do-while loop is always executed at least once.
-------------------------------- Example ---------------------------------
while (i >= 0) {
function(i);
i--;
}
The following while loop is terminated by the `break' inside the
loop.
while (1) {
value = search(value);
if (value == 0)
break; /* Terminates the while loop */
}