Unit 7 · Lesson 5
Build the idea
Start with the concept and its key vocabulary.
A counter records how many matching events occur; an accumulator combines values into a running total. Both usually start at zero before the loop. Inside the loop, update them using their previous value, such as count = count + 1 or total = total + score.
A variable updated to record how many times an event has occurred.
A variable that stores a running total or combined result.
Give a variable its starting value before it is first used.
Increase a stored number and save the new value.