Namespaces
Variants
Views
Actions

do-while loop

From cppreference.com
< c‎ | language
Revision as of 15:24, 3 April 2013 by 146.115.96.136 (Talk)

Executes a loop.

Used where code needs to be executed several times while some condition is present. The code is executed at least once.

Contents

Syntax

do Template:sparam while ( Template:sparam );

Explanation

Template:sparam shall be an expression, whose result is convertible to bool. It is evaluated after each execution of Template:sparam. The loop continues execution only if the Template:sparam 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.

Keywords

do, while

Example