liveBook · Manning

Continue statement

As explained in Modern C, Third Edition

A continue statement skips the remaining body of the current loop iteration and proceeds with that loop's next iteration step.

A continue statement skips the remaining statements in a loop's compound statement for the current iteration. Control then reevaluates the loop condition and, when true, begins the next iteration. 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) < ε) {       // Stops if close enough
    break;
  }
  x *= (2.0 - prod);                // Heron approximation
}

This loop uses continue to handle values greater than 1 before computing the product; the skipped statements do not run for that iteration. section 3.2

TAKEAWAY:

  • Use continue to separate an iteration-specific case from the main loop computation. section 3.2
  • Unlike break, continue does not stop the loop; it proceeds through condition reevaluation. section 3.2

How Modern C, Third Edition covers it

How deep it goes
Explains skipped statements and condition reevaluation through an inverse-approximation loop, without covering deeper implementation mechanics.
Examples
Uses an iterative multiplicative-inverse approximation that continues after values are moved to the correct side of 1.
What it assumes
Assumes familiarity with iteration statements, loop conditions, and compound statements.
What you can do after
Apply continue to skip selected loop-body work while allowing later iterations to proceed.
How it connects
Connects continue with break, for statements, while statements, do statements, compound statements, and loop conditions.

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, Third Edition. The section links point to the parts of the book it draws on.