Recall & Review
beginner
What is the main purpose of a loop in programming?
A loop repeats a block of code multiple times until a condition is met or no longer true.
Click to reveal answer
beginner
In a
for loop, what are the three main parts controlling the loop execution?Initialization (runs once), condition (checked before each iteration), and update (runs after each iteration).
Click to reveal answer
beginner
What happens if the loop condition is false at the start of a
while loop?The loop body does not run at all, and the program continues after the loop.
Click to reveal answer
intermediate
How does a
do-while loop differ from a while loop in execution flow?A
do-while loop runs the loop body first, then checks the condition, so it always runs at least once.Click to reveal answer
intermediate
What is the role of the
break statement inside a loop?It immediately stops the loop and exits it, skipping any remaining iterations.
Click to reveal answer
Which part of a
for loop runs only once at the start?✗ Incorrect
Initialization sets up the loop variable and runs only once before the loop starts.
What happens if the condition in a
while loop is false initially?✗ Incorrect
If the condition is false at the start, the
while loop body is skipped entirely.Which loop guarantees the body runs at least once?
✗ Incorrect
The
do-while loop runs the body first before checking the condition.What does the
break statement do inside a loop?✗ Incorrect
break exits the loop immediately, no further iterations run.In a
for loop, when is the update step executed?✗ Incorrect
The update step runs after each loop iteration to change the loop variable.
Explain the execution flow of a
for loop in C++.Think about the order of steps in the loop.
You got /4 concepts.
Describe the difference between
while and do-while loops in terms of execution flow.Focus on when the condition is checked.
You got /4 concepts.