while repeats as long as the test stays true. You must change the variable inside the body.
A countdown prints 3, then 2, then 1, then stops. while is a natural voice here: keep going as long as n is still greater than zero, print n, then subtract one.
start
test
body
step
Each step highlights the matching C line. Program output appears only when a line that prints actually runs.
Five questions. Pick one answer each, then Check answers. The correct choice turns green.
1. This lesson uses:
while (n > 0).
2. Output is:
Print then decrement.
3. If you forget n-- :
n stays 3.
4. A for countdown could look like:
for can count down too.
5. do-while vs this while:
Body before test.