##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# while loop

From cppreference.com
< c‎ | language

Executes a loop.

Used where code needs to be executed several times while some condition is present.

### [edit] Syntax

`while (` cond_expression `)` loop_statement |  |

### [edit] Explanation

cond_expression shall be an expression, whose result is convertible to bool. It is evaluated before each execution of loop_statement, which is only executed if the cond_expression evaluates to true.

If the execution of the loop needs to be terminated at some point, break statement can be used as terminating statement.

If the execution of the loop needs to be continued at the end of the loop body, continue statement can be used as shortcut.

### [edit] Keywords

`while`

### [edit] Example

| This section is incomplete Reason: no example

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/language/while&oldid=48943"
Category:

- Todo no example