Example 1 — Trace a loop in a flowchart
Show the steps and the answer
Begin with n = 4 and total = 0, then go to the diamond.
The rectangle before the diamond runs once, so total starts at 0 before the loop begins.
Go round the loop while the diamond says Yes: total becomes 4 (n = 3), 7 (n = 2), 9 (n = 1), 10 (n = 0).
Each Yes adds the current n, lowers n by 1, and the arrow returns to the same question.
Ask the diamond again with n = 0: 0 > 0 is No, so follow the No arrow to Output total.
The loop exits only when the condition fails; this last check is where an off-by-one mistake would show.
Output 10, then End.
The chart has added 4 + 3 + 2 + 1, so it sums the whole numbers from n down to 1.
Answer: It outputs 10.
Takeaway: Trace a flowchart with a small table of variable values, one arrow at a time; any arrow that returns to an earlier diamond is a loop.