0
0
Cprogramming~5 mins

Loop execution flow - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of a loop in C programming?
A loop repeats a block of code multiple times until a condition is no longer true.
Click to reveal answer
beginner
Describe the flow of a for loop in C.
A for loop starts by initializing a variable, then checks a condition before each iteration, executes the loop body if true, and updates the variable 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 execute even once, and the program continues after the loop.
Click to reveal answer
intermediate
How does a do-while loop differ in execution flow from a while loop?
A do-while loop executes 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?
The break statement immediately stops the loop and transfers control to the code after the loop.
Click to reveal answer
What part of a for loop runs only once at the beginning?
AInitialization
BCondition check
CLoop body
DIncrement/Update
When does the condition in a while loop get checked?
AOnly once at the start
BAfter each iteration
CBefore each iteration
DNever
Which loop guarantees the body runs at least once?
A<code>while</code> loop
B<code>do-while</code> loop
C<code>for</code> loop
DNone of these
What happens if the loop condition is false at the start of a for loop?
ALoop body runs once
BProgram crashes
CLoop runs infinitely
DLoop body does not run
What does the break statement do inside a loop?
AEnds the loop immediately
BPauses the loop
CRestarts the loop
DSkips current iteration
Explain the execution flow of a for loop in C.
Think about what happens first, then what repeats.
You got /5 concepts.
    Describe the difference in execution flow between a while loop and a do-while loop.
    One checks condition before running, the other after.
    You got /3 concepts.