while statement

while statement Test-at-top unbounded loop statement

statement := while ( condition ) statement

condition ::= expression | type-specifier-seq declarator = assignment-expr

The while loop tests condition, and if condition is true, while executes statement. This repeats until condition is false. If condition contains a declaration, the declaration is in the same scope as statement.


while (cin >> num)


See Also

break, continue, do, expression, for, statement, Chapter 4