A reliable tracing method
An assignment stores a value in a variable. Selection chooses a branch; iteration repeats instructions. A condition evaluates to true or false. You need these meanings before filling the table.
Read the code and table headings
Identify the variables, inputs, conditions and output. Follow any given starting row and instructions. Do not invent a value for a variable that has not been assigned.
Work out the right-hand side first
For an update such as
total ← total + n, use the current values to calculate the result, then replace total. Keep the old value in its earlier trace row.Follow the actual path
An IF executes its true branch or its ELSE branch, not both. A WHILE tests its condition before entering the body and tests again after each completed iteration.
Keep output separate from working
A changing variable is not automatically displayed. Enter output only at OUTPUT, print or the equivalent instruction in the question.
Check the stopping point
For a WHILE loop, evaluate the condition once more after the last update. A false result exits the loop; any statements after it still run.

