ConceptStep · learning platform for computer science

Accumulator inside a loop

Scratch and algorithmic thinking · Lesson

Scratch · lesson 19 / 25

Accumulator inside a loop

Distinguish an accumulator from a counter and update a running sum.

1 · Explanation

The concept

An accumulator does not count iterations: it progressively combines processed values, for example by building a sum.

Mental model:

sum=0; REPEAT { sum=sum+value }

2 · Mind map

Build the concept in your mind

This is a starter map for the lesson concept. You can move and edit nodes, add new ones and create your own connections. Changes stay on this device and do not affect mastery assessment.

Key idea Pattern Scratch Common mistake Check

Double-click a node to edit it. Drag nodes and add the connections that help you remember the concept.

3 · Live example

Observe the behaviour

Press Run and carefully observe block order, the Stage and variable state. The Scratch environment intentionally remains in English.

Stage
Press Run to start the program.
Ready to run.
4 · Guided practice

Now build it yourself

Use counter and sum to add 2+3+4+5 in a loop; the result must be 14.

Guide:

Some key blocks are detached and shown beside the program. Drag them into the correct positions and also check values or operators that may be deliberately wrong.

Progress: 0 / 5 · correct: 0

Stage
Press Run to test your program.
Run the program freely: local runs do not change your progress.

When you think the program is correct, ConceptStep will also test it with inputs you cannot see.

5 · Algorithmic connection

From Scratch to flowchart and C

The mental model in this lesson does not belong to Scratch: it describes a programming concept. Later the same exercise can be represented as a flowchart and then as a C program while keeping the same test cases.

← Previous lesson Next lesson →
Your competency map

What you need to know for Accumulator inside a loop

ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.

Current topic Strong skill Review due Needs reinforcement To be mastered Optional support

Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.

GUIDED LEARNING PATHS

Want to choose the next skill to develop?