liveBook · Manning

Continue statement

As explained in Modern C

A continue statement is a C control-flow statement that skips the remainder of the current loop iteration and proceeds with the loop's next control check.

A continue statement skips the rest of the current loop body and proceeds to the loop’s next control check. In this inverse-computation loop, values greater than 1 are inverted, then continue prevents the remaining calculation from running on that iteration. section 3.2

Correcting the iteration side

for (size_t i = 0; i < max_iterations; ++i) { if (x > 1.0) { x = 1.0 / x; continue; } double prod = a * x; if (fabs(1.0 - prod) < eps) { break; } x *= (2.0 - prod); } Here, continue bypasses prod computation, the stopping test, and the update for the current pass. The for statement then performs its next control step. section 3.2

for (size_t i =0; i < max_iterations; ++i) {
  if (x > 1.0) {   // Checks if we are on the correct side of 1
    x = 1.0/x;
    continue;
  }
  double prod = a*x;
  if (fabs(1.0 - prod) < eps) {     // Stops if close enough
    break;
  }
  x *= (2.0 - prod);                // Heron approximation
}


!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":0,\"ch\":5},{\"line\":0,\"ch\":11}],[{\"line\":1,\"ch\":2},{\"line\":1,\"ch\":4}],[{\"line\":6,\"ch\":2},{\"line\":6,\"ch\":4}],[{\"line\":3,\"ch\":4},{\"line\":3,\"ch\":12}],[{\"line\":5,\"ch\":2},{\"line\":5,\"ch\":8}],[{\"line\":1,\"ch\":2},{\"line\":1,\"ch\":4}],[{\"line\":6,\"ch\":2},{\"line\":6,\"ch\":4}],[{\"line\":6,\"ch\":6},{\"line\":6,\"ch\":10}],[{\"line\":7,\"ch\":4},{\"line\":7,\"ch\":9}]]"}
!@%STYLE%@!

Inspect the complete bounded loop showing continue alongside break and the Heron approximation. section 3.2

How Modern C covers it

How deep it goes
Demonstrates continue operationally in a bounded for loop, but does not develop broader control-flow rules.
Examples
Illustrates continue while computing multiplicative inverses with the Heron approximation.
What it assumes
Assumes familiarity with for loops, loop conditions, iteration expressions, and break.
What you can do after
Apply it in C loop bodies to skip remaining work for selected iterations without terminating the loop.
How it connects
Connects continue with for loops, loop conditions, iteration expressions, and break.

Also explained in

Compare how 5 books explain continue statement →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.