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
- Starttotal = 0
- ReadTake the next value
- Updatetotal = total + value
- RecordWrite the new state
- RepeatContinue through the list
- 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.