Read n, then print every integer from 1 through n, each on its own line.
You read n, then print every integer from 1 through n, each on its own line. The loop variable i is both the counter and the thing you print.
sample n is 3
A while version would still start i at 1.for header test
do-while would print once even if n were 0 — different kind.body
One number per line.step
Same role as i++ at the end of a while body.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. n = 3 prints:
i from 1 to n.
2. The test i <= n is checked:
for test.
3. A while version needs you to:
while has no built-in step.
4. do-while would print at least:
Body first.
5. When i becomes n+1:
Leave for.