Same idea, three dialects: for when you know the count, while when you do not, do-while when the body must run at least once.
1 for
Bundles init; condition; update on one line — best when the number of passes is known.
2 while
Checks first, runs after. A false condition from the start means zero passes.
3 do-while
Runs the body first, checks later — the body always executes at least once.
4 break & continue
break exits the loop early; continue skips straight to the next pass.
Three ways to repeat
for1Bundles init; condition; update on one line — best when the number of passes is known. while2Checks first, runs after. A false condition from the start means zero passes.
do-while3Runs the body first, checks later — the body always executes at least once. break & continue4break exits the loop early; continue skips straight to the next pass. 4 building blocks make up Three ways to repeat
The condition gate is revisited after every pass — that is what makes it loop.
process decision input / output start / end Two programs, two tabs — watch the for loop re-check its condition line, then a do-while that acts before it thinks.
preprocessThe preprocessor pastes in stdio.h.
Memory
no variables yet — press play
Console
output appears as the program runs…
A while loop that shrinks n by 2 each pass — where does it stop?
Your predicted output — one line per console line
Hint: The loop prints n before shrinking it, and stops the moment n > 3 is false — n ends at 2.
Click a keyword, then click its job to lock the pair.
5 conceptsTap a card to expand ?fordrops into place
?whiledrops into place
?do-whiledrops into place
?breakdrops into place
?continuedrops into place
01for packs init; condition; update into one line — use it for counting.
02while checks before each pass; do-while checks after and always runs once.
03Every loop needs a start, a condition that can turn false, and progress toward it.
04break leaves the loop now; continue jumps to the next pass.
05i = i + 2 walks the counter in bigger steps — handy for evens.