Add every integer from 1 through n into a running total.
A running total starts at zero. Each pass of the loop adds the next integer. When the loop finishes you print once — the finished sum, not the partials.
start
loop
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 = 4 prints:
1+2+3+4=10.
2. sum starts at:
Empty total.
3. If you printf inside the loop you would get:
Print once after.
4. This running total is a:
for i = 1..n.
5. while (i <= n) { sum += i; i++; } compared to for:
Equivalent pattern.