Cloudbook: C

  1. Home
  2. Control
  3. Iteration
  4. § 2 exercise →
Break and Continue

The control flow for looping constructs can be altered with continue and break statements. The complete list of looping constructs that accept break and continue statements are:

  • while statements
  • do-while statements
  • and for statements
In addition to the use of break in looping constructs, break is also available inside the branching construct of the switch statement.

A continue statement in a loop body will immediately send control to the end of the loop body. A continue statement will skip over the remaining body of the loop but will continue the evaluation with the check of the condition and future loop body evaluations.

A break statement immediately sends control to the next statement after the loop construct.

C also provides a do-while loop that differs from the while loop in that the controlling conditional is checked at the bottom of the loop, and not before the first time through the loop. If the body of the loop contains no breaks or continues, then a do-while checks the condition as many times as the body is executed, whereas a while checks the condition one more time than that.