Free practice · numeric · easy

Practice

Trace a loop total

Start total at 0. For each number in [2, 4, 6], add the number to total. What is total afterward?

Running-total trace

State changes once for every processed value

  1. Starttotal = 0
  2. ReadTake the next value
  3. Updatetotal = total + value
  4. RecordWrite the new state
  5. RepeatContinue through the list
  6. CheckCompare with a hand total

Record the total after each addition. The final value is verified only after every input has been processed exactly once.