← IGCSE Computer Science Paper 2

Counting: how it works

Counting adds 1 to a counter each time something happens. Start the counter at 0, add 1 (not the item's value), and do it for every item or only for matches.

Understanding Counting: how it works in IGCSE Computer Science Paper 2

What it does: Putting the counter update inside an IF means only matching items are counted, instead of every item. A counter starts at 0 because nothing has been counted yet. Starting at 1 would make the final answer one too high. Counting always adds 1, no matter what the item is. Adding the item's value is totalling, not counting. Count + 1 counts items. Count + Number adds up the values, which is totalling. 'How many' is counting. 'The sum of' is totalling.

Common mistakes: Counting adds 1 each time, not the item's value. Adding Mark makes a total, not a count. It should be Count ← Count + 1. The condition only matches marks of exactly 50, so passes above 50 are missed. To count every pass it should be IF Mark[Index] >= 50 THEN.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 275–285) and word search (Modules 275–295).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Before a counting loop starts, what should the counter be set to?
Count ← 0Count ← 1
Matches
Count ← Count + Mark[Index]
↓
This adds the item's value to the counter instead of adding 1. That is totalling, not counting.
Applying
Meanings
Term
Count ← Count + 1
Meaning
Counting adds 1 to a counter each time something happens. Start the counter at 0, add 1 (not the item's value), and do it for every item or only for matches.
Practice
Count ← 0
Testing
Gaps
Count ←
Check Answer
Spots
3 INPUT Mark
4 Count ← Count + Mark

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Woodpecker' badge — Tap Tap Tap, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Before a counting loop starts, what should the counter be set to?
A. Count ← 0 ✓
B. Count ← 1
A counter starts at 0 because nothing has been counted yet. Starting at 1 would make the final answer one too high.
2. Each time an item is counted, what is added to the counter?
A. Count ← Count + Mark[Index]
B. Count ← Count + 1 ✓
Counting always adds 1, no matter what the item is. Adding the item's value is totalling, not counting.
3. Which statement about counting is TRUE?
A. Counting adds 1 each time something happens ✓
B. Counting adds the value of each item to the counter
Counting tracks HOW MANY times something happens. Adding the values up is a different method called totalling.
4. An array holds 5 test marks (60, 45, 80, 92, 70). The algorithm counts every mark. What is Count at the end?
A. 5 ✓
B. 347
Counting adds 1 for each of the 5 marks, so Count is 5. 347 is what you get by totalling the marks.
5. Which algorithm counts only the marks above 50?
A. Count ← Count + 1 for every mark, with no IF
B. IF Mark[Index] > 50 THEN Count ← Count + 1 ENDIF ✓
To count only matches, put Count ← Count + 1 inside an IF that tests the condition. Without the IF, every item is counted.

Match the Pairs

Count ← 0 → Sets the counter to 0 before the loop starts, so nothing has been counted yet
Count ← Count + 1 → Adds 1 to the counter each time it runs, no matter what the item's value is
Count only the items that meet a condition, such as marks over 50 → IF Mark[Index] > 50 THEN Count ← Count + 1 ENDIF
Count every item by adding 1 on each repeat of the loop → FOR Index ← 1 TO 10 Count ← Count + 1 NEXT Index
Count ← Count + Mark[Index] → This adds the item's value to the counter instead of adding 1. That is totalling, not counting.
FOR Index ← 1 TO 10 Count ← 0 Count ← Count + 1 NEXT Index → The counter is reset to 0 inside the loop, so it never builds up past 1. It must be set to 0 once, before the loop.

Key Term

Count ← Count + 1
Counting adds 1 to a counter each time something happens. Start the counter at 0, add 1 (not the item's value), and do it for every item or only for matches.

Fill in the Blanks

1. Count ← 0 FOR Index ← 1 TO 10 Count ← Count + 1
Hint: Type the value the counter should have before any items are counted.
2. Count ← 0 FOR Index ← 1 TO 10 Count ← Count + 1
Hint: Type the fixed amount added to the counter each time, not the item's value.
3. FOR Index ← 1 TO 10 Count ← Count + 1 NEXT Index
Hint: Type the counter variable that is read on the right so its old value is kept and increased.
4. IF Score > 50 THEN Count ← Count + 1 ENDIF
Hint: Type the comparison operator for 'greater than' so only matching items are counted.
5. IF Colour = "Red" THEN Count ← Count + 1 ENDIF
Hint: Type the keyword that closes the selection, so only matching items add to the counter.

Spot the Error

Question 1
A Count ← 0
B FOR Index ← 1 TO 10
C INPUT Mark
D Count ← Count + Mark
E NEXT Index
F OUTPUT Count
Line D — Counting adds 1 each time, not the item's value. Adding Mark makes a total, not a count. It should be Count ← Count + 1.
Question 2
A Count ← 0
B FOR Index ← 1 TO 10
C IF Mark[Index] = 50 THEN
D Count ← Count + 1
E ENDIF
F NEXT Index
Line C — The condition only matches marks of exactly 50, so passes above 50 are missed. To count every pass it should be IF Mark[Index] >= 50 THEN.
Question 3
A INPUT Mark
B Count ← 1
C WHILE Mark <> -1 DO
D Count ← Count + 1
E INPUT Mark
F ENDWHILE
Line B — A counter must start at 0. Starting at 1 makes every answer one too high. It should be Count ← 0.
Question 4
A Count ← 5
B REPEAT
C INPUT Number
D Count ← Count + 1
E UNTIL Count = 10
F OUTPUT Count
Line A — The counter must start at 0 before counting begins. Starting at 5 gives a wrong count. It should be Count ← 0.
Question 5
A Count ← 0
B FOR Index ← 1 TO Count
C IF Age[Index] >= 18 THEN
D Count ← Count + 1
E ENDIF
F NEXT Index
Line B — The loop must check all 20 items, but Count is 0 at the start so the loop would not check them. It should be FOR Index ← 1 TO 20.

Student with a class code? Join your class →