Contents

any expression which is contextually convertible to bool or a declaration of a single variable with a brace-or-equals initializer. This expression is evaluated before each iteration, and if it yields false, the loop is exited. If this is a declaration, the initializer is evaluated before each iteration, and if the value of the declared variable converts to false, the loop is exited.

statement

-

any statement, typically a compound statement, which is the body of the loop

If statement is a single statement (not a compound statement), the scope of variables declared in it is limited to the while loop as if it was a compound statement, in other words,

while(--x >=0)int i;// i goes out of scope

is the same as

while(--x >=0){int i;}// i goes out of scope

If condition is a declaration such as T t = x, the declared variable is only in scope in the body of the loop, and is destroyed and recreated on every iteration, in other words, such while loop is equivalent to