0
0
C++programming~5 mins

Continue statement in C++ - 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 immediately starts 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.
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
True or False: The continue statement exits the entire loop.
False. continue skips to the next iteration but does not exit the loop. The break statement exits the loop.
Click to reveal answer
beginner
Example: What will be the output of this code?<br>
for (int i = 1; i <= 5; i++) {
  if (i == 3) continue;
  std::cout << i << " ";
}
The output will be: 1 2 4 5 <br>The number 3 is skipped because when i == 3, continue skips printing it.
Click to reveal answer
What does the continue statement do inside a loop?
APauses the loop until user input
BExits the entire loop immediately
CSkips the rest of the current iteration and starts the next iteration
DRestarts the program
In a for loop, what happens after a continue statement is executed?
AThe loop variable resets to zero
BThe loop ends immediately
CThe program crashes
DThe loop variable is updated and the next iteration begins
Can continue be used in a while loop?
AYes, it skips to the next iteration
BNo, it only works in <code>for</code> loops
COnly if the loop has a break
DOnly inside functions
What is the difference between continue and break?
A<code>continue</code> exits the loop; <code>break</code> skips iteration
B<code>continue</code> skips to next iteration; <code>break</code> exits the loop
CBoth do the same thing
DNeither affects the loop
If continue is used inside nested loops, which loop does it affect?
AOnly the innermost loop where it appears
BAll loops at once
COnly the outermost loop
DIt causes an error
Explain how the continue statement changes the flow inside a loop.
Think about what happens when you want to skip some steps but keep looping.
You got /3 concepts.
    Describe a real-life example where using continue in a loop would be helpful.
    Imagine sorting mail and skipping junk mail without stopping the whole process.
    You got /3 concepts.