Topic 8 Β· Programming Β· 8.9

Counting Explained Simply

Counting means recording how many times something happens. Each time the event occurs, the counter increases by one.

Invitation

How does a program record how many times something happens?

A program may need to count passes, incorrect answers, items sold or values that match a condition.

Counting uses a variable called a counter. Whenever the event happens, the counter increases by one.

Start at zero. Check the condition. Add one when it is true.
Figure 1
A simple counter
Counter starts at 0
↓
Event happens
+ 1
Counter becomes 1
Big Idea

A counter increases by one

The statement Count <- Count + 1 takes the old value of Count, adds one, then stores the new value back in the counter.

This statement is usually placed inside an IF statement and a loop. The loop checks several values, while the IF statement decides whether the counter should increase.

A counter records frequency: how many times an event occurs.
Figure 2
How the counter changes
Old count: 3
+ 1
New count: 4
FutureLogic Bridge

Counting is like pressing a click counter

Imagine a teacher counting students as they enter a room. Each student who walks through the door causes one click.

The click counter does not add the students' ages, names or heights. It only records how many students have entered.

One matching event means one click and one added to the counter.
Figure 3
The click-counter bridge
Student enters
CLICK
Count: 1
CLICK
Count: 2
Worked Example

Count how many marks are 50 or more

The program checks four marks. Each time a mark is 50 or more, the counter increases by one.

PseudocodeCounting routine
PassCount <- 0
FOR Count <- 1 TO 4
    INPUT Mark
    IF Mark >= 50 THEN
        PassCount <- PassCount + 1
    ENDIF
NEXT Count
OUTPUT PassCount
PythonEquivalent idea
pass_count = 0
for count in range(4):
    mark = int(input("Enter a mark: "))
    if mark >= 50:
        pass_count = pass_count + 1
print(pass_count)

Follow the count

62Pass β†’ count becomes 1
41Not a pass β†’ count stays 1
75Pass β†’ count becomes 2
50Pass β†’ count becomes 3
Final output: 3
Exam Tip

Counting usually needs selection and iteration

The loop checks every value. The IF statement tests the condition. The counter increases only when that condition is true.

Strong pattern:
Count <- 0
IF condition THEN
    Count <- Count + 1
ENDIF
OUTPUT Count

Look carefully for words such as count, how many or number of in exam questions.

Common Mistake

Adding the value instead of adding one

Counting and totalling use a similar pattern, but they do different jobs.

Incorrect for counting: Count <- Count + Mark
Correct: β€œIncrease the counter by one each time the condition is true.”

Totalling adds the value. Counting adds one.

Summary

The counting pattern

InitialiseSet the counter to zero.
LoopCheck each value or event.
TestUse an IF statement for the condition.
CountAdd one when the condition is true.
KeepThe variable stores the updated count.
OutputDisplay the final count after the loop.