What does the continue statement do inside a loop in C#?
The continue statement skips the rest of the current loop iteration and moves control to the next iteration of the loop.
Click to reveal answer
beginner
In which types of loops can you use the continue statement in C#?
You can use continue in for, while, and do-while loops in C#.
Click to reveal answer
intermediate
What happens if continue is used inside a nested loop?
The continue statement affects only the innermost loop where it is used, skipping to the next iteration of that loop.
Click to reveal answer
beginner
Can continue be used outside of loops in C#?
No, continue can only be used inside loops. Using it outside will cause a compile-time error.
Click to reveal answer
beginner
How does continue differ from break in loops?
continue skips the rest of the current iteration and moves to the next one, while break exits the entire loop immediately.
Click to reveal answer
What does the continue statement do in a for loop?
ARestarts the entire loop from the beginning
BExits the loop completely
CPauses the loop until a condition is met
DSkips the rest of the current iteration and starts the next iteration
✗ Incorrect
continue skips the remaining code in the current iteration and moves to the next iteration of the loop.
Where can the continue statement NOT be used?
AOutside any loop
BInside a <code>do-while</code> loop
CInside a <code>for</code> loop
DInside a <code>while</code> loop
✗ Incorrect
continue can only be used inside loops. Using it outside causes a compile error.
In nested loops, which loop does continue affect?
AThe outermost loop
BAll loops simultaneously
CThe innermost loop where <code>continue</code> is used
DNone of the loops
✗ Incorrect
continue affects only the innermost loop it is inside, skipping to its next iteration.
What is the difference between continue and break?
A<code>continue</code> exits the loop; <code>break</code> skips to next iteration
B<code>continue</code> skips to next iteration; <code>break</code> exits the loop
CBoth do the same thing
DNeither affects loop execution
✗ Incorrect
continue skips the rest of the current iteration, break exits the loop entirely.
What happens if continue is used in a do-while loop?
AIt skips to the next iteration after checking the condition
BIt exits the loop immediately
CIt causes a syntax error
DIt restarts the loop from the beginning
✗ Incorrect
In a do-while loop, continue skips to the condition check and then starts the next iteration if true.
Explain how the continue statement changes the flow inside a loop.
Think about what happens after <code>continue</code> is executed inside a loop.
You got /3 concepts.
Describe the difference between continue and break statements in loops.
One stops the loop, the other skips part of it.
You got /3 concepts.
Practice
(1/5)
1. What does the continue statement do inside a loop in C#?
easy
A. Stops the entire loop immediately
B. Skips the rest of the current loop iteration and moves to the next one
C. Exits the current method
D. Repeats the current iteration without moving forward
Solution
Step 1: Understand the role of continue in loops
The continue statement tells the loop to skip the remaining code in the current iteration.
Step 2: Identify what happens after continue
After skipping, the loop moves to the next iteration without stopping the whole loop.
Final Answer:
Skips the rest of the current loop iteration and moves to the next one -> Option B
Quick Check:
continue skips current iteration [OK]
Hint: Remember: continue skips current loop step, not whole loop [OK]
Common Mistakes:
Confusing continue with break
Thinking continue exits the method
Assuming continue repeats the iteration
2. Which of the following is the correct syntax to use continue inside a for loop in C#?
easy
A. continue;
B. continue()
C. continue {}
D. continue[]
Solution
Step 1: Recall the syntax of continue
In C#, continue is a statement and must be followed by a semicolon.
Step 2: Check each option
Only continue; is valid syntax. The others use parentheses, braces, or brackets incorrectly.
Final Answer:
continue; -> Option A
Quick Check:
Correct syntax ends with semicolon [OK]
Hint: Use semicolon after continue, no parentheses [OK]
Common Mistakes:
Adding parentheses after continue
Using braces or brackets with continue
Omitting the semicolon
3. What will be the output of the following C# code?
for (int i = 1; i <= 5; i++) {
if (i == 3) continue;
Console.Write(i + " ");
}
medium
A. 2 3 4 5
B. 1 2 3 4 5
C. 1 2 3 4
D. 1 2 4 5
Solution
Step 1: Analyze the loop and condition
The loop runs from 1 to 5. When i equals 3, continue skips printing.
Step 2: Determine printed values
Numbers 1, 2, 4, and 5 are printed with spaces. Number 3 is skipped.
Final Answer:
1 2 4 5 -> Option D
Quick Check:
continue skips printing 3 [OK]
Hint: Skip printing when continue triggers, others print [OK]
Common Mistakes:
Including the skipped number in output
Confusing continue with break
Ignoring spaces in output
4. Identify the error in this C# code snippet using continue:
int i = 0;
while (i < 3) {
if (i == 1)
continue;
Console.Write(i);
i++;
}
medium
A. Syntax error: continue cannot be used in while loop
B. Missing semicolon after continue
C. Infinite loop because i++ is skipped when i == 1
D. Console.Write should be Console.WriteLine
Solution
Step 1: Understand loop behavior with continue
When i == 1, continue skips i++, so i stays 1 forever.
Step 2: Identify the problem caused
The loop never increments i past 1, causing an infinite loop.
Final Answer:
Infinite loop because i++ is skipped when i == 1 -> Option C
Quick Check:
continue skips i++ causing infinite loop [OK]
Hint: Ensure increments run before continue to avoid infinite loops [OK]
Common Mistakes:
Thinking continue causes syntax error
Ignoring loop variable increment
Assuming Console.WriteLine fixes logic
5. You want to print all even numbers from 1 to 10 but skip printing 6 using a for loop and continue. Which code snippet correctly does this?
hard
A. for (int i = 2; i <= 10; i += 2) { if (i == 6) continue; Console.Write(i + " "); }
B. for (int i = 1; i <= 10; i++) { if (i % 2 == 0 && i != 6) Console.Write(i + " "); }
C. for (int i = 2; i <= 10; i++) { if (i % 2 == 0) Console.Write(i + " "); if (i == 6) continue; }
D. for (int i = 2; i <= 10; i += 2) { if (i == 6) break; Console.Write(i + " "); }
Solution
Step 1: Understand the goal
Print even numbers 2,4,8,10 but skip 6 using continue inside a for loop.
Step 2: Check each option
for (int i = 2; i <= 10; i += 2) { if (i == 6) continue; Console.Write(i + " "); } loops by 2, skips 6 with continue, prints others. for (int i = 1; i <= 10; i++) { if (i % 2 == 0 && i != 6) Console.Write(i + " "); } prints all evens except 6 but no continue used. for (int i = 2; i <= 10; i++) { if (i % 2 == 0) Console.Write(i + " "); if (i == 6) continue; } prints 6 because print happens before continue. for (int i = 2; i <= 10; i += 2) { if (i == 6) break; Console.Write(i + " "); } breaks at 6, stopping loop early, so 8 and 10 not printed.
Final Answer:
for (int i = 2; i <= 10; i += 2) { if (i == 6) continue; Console.Write(i + " "); } -> Option A
Quick Check:
Use continue to skip 6 in even-step loop [OK]
Hint: Loop evens, continue at 6 to skip it, print others [OK]
Common Mistakes:
Using break instead of continue
Not incrementing by 2 for evens
Skipping continue and using if only
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.