0
0
Cprogramming~10 mins

Continue statement - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Continue statement
Start loop iteration
Check condition
Yes
Check continue condition
Skip rest
Go to next
Next iteration or exit
The loop starts each iteration by checking the main condition. If the continue condition is met, it skips the rest of the loop body and jumps to the next iteration.
Execution Sample
C
for (int i = 1; i <= 5; i++) {
    if (i == 3) continue;
    printf("%d ", i);
}
This code prints numbers from 1 to 5 but skips printing 3 using the continue statement.
Execution Table
IterationiCondition (i <= 5)Continue check (i == 3)ActionOutput
11TrueFalsePrint 11
22TrueFalsePrint 22
33TrueTrueSkip print, continue to next
44TrueFalsePrint 44
55TrueFalsePrint 55
66False-Exit loop
💡 i reaches 6, condition i <= 5 is False, loop ends
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5Final
i1234566
Key Moments - 2 Insights
Why does the number 3 not get printed even though the loop reaches i=3?
At iteration 3 in the execution_table, the continue check is True, so the loop skips the print statement and moves to the next iteration.
Does the continue statement stop the whole loop?
No, as shown in the execution_table, continue only skips the current iteration's remaining code and proceeds with the next iteration until the loop condition fails.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the output when i equals 3?
A"3 " is printed
BNothing is printed
C"Continue" is printed
DLoop exits
💡 Hint
Check the row where Iteration is 3 and see the Action and Output columns.
At which iteration does the loop condition become false?
A6
B3
C5
D1
💡 Hint
Look at the last row in the execution_table where Condition (i <= 5) is False.
If the continue statement was removed, what would be the output at iteration 3?
ANothing would be printed
BLoop would exit early
C"3 " would be printed
DError occurs
💡 Hint
Refer to the Action and Output columns for iteration 3 and imagine no skipping happens.
Concept Snapshot
continue statement in C:
- Used inside loops to skip the rest of current iteration
- Control jumps immediately to next iteration check
- Syntax: if(condition) continue;
- Does NOT exit the loop, just skips current iteration
- Useful to ignore specific cases without breaking loop
Full Transcript
This example shows how the continue statement works in a C for loop. The loop runs from i=1 to i=5. When i equals 3, the continue condition is true, so the loop skips printing 3 and moves to the next iteration. For other values, it prints the number. The loop ends when i becomes 6 because the condition i <= 5 is false. The continue statement only skips the current iteration's remaining code and does not stop the whole loop.