[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
while while Statement
while (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 */
}
See Also:
do
break
return
continue
goto
return
for
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson