Recall & Review
beginner
What does the
continue statement do in a loop?It skips the rest of the current loop iteration and moves to the next iteration immediately.
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.Click to reveal answer
intermediate
What happens if
continue is used inside a nested loop?It only affects the innermost loop where it is used, skipping to the next iteration of that loop.
Click to reveal answer
beginner
Consider this code snippet:<br>
for(int i = 0; i < 5; i++) { if(i == 2) continue; printf("%d ", i); }<br>What will be the output?The output will be:
0 1 3 4 <br>The number 2 is skipped because continue skips printing when i == 2.Click to reveal answer
intermediate
Why might you use
continue instead of if-else inside a loop?Using
continue can make code cleaner by avoiding nested if-else blocks and clearly skipping unwanted cases.Click to reveal answer
What does the
continue statement do inside a loop?✗ Incorrect
The
continue statement skips the remaining code in the current loop iteration and moves to the next iteration.In which loop(s) can you use
continue in C?✗ Incorrect
continue works in all three loop types: for, while, and do-while.What happens if
continue is used inside nested loops?✗ Incorrect
continue affects only the innermost loop where it is used, skipping to the next iteration of that loop.What will this code print?<br>
for(int i=0; i<3; i++) { if(i==1) continue; printf("%d", i); }✗ Incorrect
When
i==1, continue skips printing. So only 0 and 2 are printed.Why might
continue improve code readability?✗ Incorrect
continue helps avoid deep nesting by skipping certain cases early, making code easier to read.Explain how the
continue statement works inside a loop and give a simple example.Think about what happens when you want to skip some steps but keep looping.
You got /3 concepts.
Describe a situation where using
continue makes your loop code cleaner compared to using if-else.Imagine you want to ignore some values and only process others inside a loop.
You got /3 concepts.