A while statement repeatedly runs the body of a loop until the controlling expression evaluates to 0.
The expression is evaluated to determine whether or not to process the body of the loop. The expression must be convertible to a scalar type.
If the expression evaluates to 0, the body of the loop never runs.
If the expression does not evaluate to 0, the loop body is processed. After the body has run, control passes back to the expression. Further processing depends on the value of the condition.
A break, return, or goto statement can cause a while statement to end, even when the condition does not evaluate to 0.
break Statement
goto Statement
return Statement
Example Using
the while Statement