continue;C continue Statement: Skipping the Current Loop Iteration
What is C continue Statement? Core Concept & Direct Summary
How does the `continue` statement skip the remainder of the current loop body and proceed to the next iteration?
Last time, we mastered break — the emergency exit that ends a loop entirely. But sometimes you don't want to abandon the loop. You just want to skip this particular pass and move on to the next one. A bad data entry in a list of a thousand? Skip it, process the rest. An even number when you're hunting odds? Skip, keep counting.
That's precisely the job of continue: abandon the rest of the current iteration and jump straight to the next one. If break is leaving the cinema halfway through the movie, continue is skipping a song on a playlist — the playlist itself keeps playing.
It's a small statement with subtle behavior — and one genuine trap in while loops that has caught nearly every C programmer at least once. Let's cover it properly.
(Suggested image: the hero diagram — a loop circle with iterations shown as boxes; on iteration 3, a "continue" arrow skips the remaining body code and arcs straight to the next iteration's start)
How Does C continue Statement Work? In-Depth Mechanics & Architecture
The Syntax
One keyword, one job: skip everything below it in the loop body, and start the next iteration immediately. The loop itself does not end — it carries on as long as its condition allows.
The classic first example:
Output:
Every even number triggers continue, which skips the printf for that pass only. The loop still completes all ten iterations — five of them just got cut short. Compare with the same loop using break:
Same position, same condition — completely different outcome. That's the difference in action.
continue vs break: The Definitive Comparison
Side by side, one frame at a time:
(Suggested image: this exact comparison as a two-panel infographic — this targets the very high-volume "break vs continue" query; make it excellent)
How continue Behaves in Each Loop — This Is Where It Gets Tricky
Here's the subtle part most tutorials gloss over: what "next iteration" means differs by loop type. Specifically — does the update happen or not?
In a for loop: update RUNS ✓
continue in a for jumps to the update step (i++) and then the condition. The counter still advances. Life is good.
In a while loop: update might NOT run ⚠️
But watch what happens when the update sits below the continue:
Here's the story: continue in a while jumps straight to the condition check — nothing else. The i++ below never executes, i stays 3, the condition stays true, and the loop spins forever. The condition i == 3 keeps matching, continue keeps firing, and i++ is permanently ghosted.
The rule: in while and do-while, make sure your update happens before any possible continue — or your loop may never move again.
In a do-while loop: jumps to the condition
continue here jumps to the condition check at the bottom. Same update-placement rule as while — update first, skip second.
(Suggested image: a three-row diagram showing exactly where continue jumps in for (→ update), while (→ condition), do-while (→ condition). This visual explains the trap better than any paragraph.)
The Classic Use Cases
Filtering input — process only valid entries:
Sample Run:
Skipping specific values — print 1–20 except multiples of 3:
Guard-clause style — keep the main logic flat:
That last pattern is quietly one of the most valuable uses of continue: instead of wrapping real work in layer after layer of if, you reject the bad cases up front and keep the happy path at normal indentation. It pairs beautifully with the "guard clauses" idea from our nested-if tutorial.
continue in Nested Loops
Same rule as break: continue affects only the loop it physically sits in:
Output:
Only the inner loop skips; the outer loop never even notices. [1,1], [2,2], [3,3] — the diagonal — vanished, and everything else printed. (Handy trivia: this exact pattern is how you skip matrix diagonals, coming soon in the arrays section.)
The Common continue Mistakes
- The while-loop infinite trap — update below
continuenever runs. The #1continuebug, worth repeating until it sticks. - Confusing it with break —
continuedoesn't end anything; the loop lives on. If your loop "should have stopped," check whether you wantedbreak. - Using it in switch expecting to skip cases — illegal;
continuebelongs to loops only. (If the switch sits inside a loop,continueskips to the loop's next iteration — legal, but read it twice before writing it.) - Code after continue in the same block — unreachable dead code:
- Using it where a plain if reads better:
continueearns its place when there are multiple skip conditions or deep nesting to avoid. For a single simple condition, an invertedifis often clearer. Judgment, not dogma.
(Suggested image: "5 continue Mistakes" checklist graphic — consistent with the series)
A Complete Example: Report Card Processor
Sample Run:
Two different continues doing two different jobs — one filtering absentees, one forcing re-entry on invalid input — while the average correctly excludes both. That's filtering logic exactly as it appears in real programs.
Final Thoughts
continue completes your loop-control toolkit. Where break ends the story, continue just turns the page — skipping the parts that don't matter while keeping the loop's momentum. Filtering, validation, guard clauses: anywhere a loop meets imperfect data, continue is how you say "not this one — next."
Burn the one real trap into memory: in while and do-while, update before you continue. Do that, and this little statement will never hurt you.
And with that — the Control Flow cluster is complete. Decisions (if, if-else, nested, switch), loops (for, while, do-while), and jumps (break, continue): you now hold every tool C gives you for controlling what runs and when. Everything from here — arrays, functions, pointers — builds on this foundation.
Runnable C Code Example & Practical Implementation
#include <stdio.h>
int main() {
printf("Printing odd numbers between 1 and 10:\
");
for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
continue;
// Skip even numbers
}
printf(" %d\
", i);
}
return 0;
}Key Takeaways, Best Practices & Memory Safety Rules
continue statements in while loops, or prefer for loops where increments are handled in the header.Frequently Asked Questions & Technical Interview Insights
Technical Interview & Viva Questions
Frequently asked C programming interview questionsQ: What is the danger of using `continue` inside a `while` loop?
Q: What is the difference between `break` and `continue`?
Related Tools, Tutorials & Authoritative References
Recommended Interactive Tools
- Online C Compiler & Runner — Interactive online GCC sandbox to execute C code in real time.
- Online C Code Editor & IDE — Multi-file C programming environment with code formatting.
- C++ Programming Tutorial — Transition from procedural C to Object-Oriented C++ with STL.
- JavaScript Programming Tutorial — Master modern JavaScript fundamentals, DOM APIs, and async patterns.
Authoritative Standards & Citations
- ISO/IEC 9899 (C Language Standard) — Official international C specification by ISO/IEC JTC 1/SC 22/WG 14.
- GNU GCC Documentation — Official reference manual for the GNU Compiler Collection and C libraries.
- The C Programming Language (K&R) — Definitive classic work by Brian Kernighan & Dennis Ritchie at Bell Labs.
- C Reference Documentation (cppreference.com) — Verified reference covering C89 through C23 language features.