Introducing the while()… statement
The while()…
statement has the following syntax:
while( continuation_expression ) statement_body
It consists of a continuation_expression
and a loop body. At each iteration of the while loop, the continuation_expression
is evaluated. If its result is true
, statement_body
is executed and continuation_expression
is evaluated again. When the continuation_expression
evaluates to false
, the loop ends; the execution resumes after statement_body
. If continuation_expression
initially evaluates to false
, the statement_body
loop is never executed.
statement_body
is – or may be – a single statement, or even the null
statement (a single ;
without an expression), but most often, it is a compound statement. Note that there is no semicolon specified as a part of the while()…
statement. A semicolon would appear as a part of a single statement in statement_body
, or would be absent in the case of statement_body
consisting...