0
0
Cprogramming~5 mins

Continue statement - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ASkips the rest of the current iteration and starts the next iteration
BExits the loop completely
CPauses the loop until user input
DRestarts the entire program
In which loop(s) can you use continue in C?
AOnly <code>for</code> loops
BOnly <code>while</code> loops
COnly <code>do-while</code> loops
D<code>for</code>, <code>while</code>, and <code>do-while</code> loops
What happens if continue is used inside nested loops?
AIt exits all loops immediately
BIt skips the rest of all loops
CIt skips the rest of the innermost loop only
DIt causes a compile error
What will this code print?<br>
for(int i=0; i<3; i++) { if(i==1) continue; printf("%d", i); }
A012
B02
C123
D13
Why might continue improve code readability?
AIt avoids nested <code>if-else</code> blocks by skipping unwanted cases
BIt automatically documents the code
CIt replaces all <code>break</code> statements
DIt makes loops run faster
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.