← IGCSE Computer Science Paper 1

Bar code check digit

The last digit of a bar code number, worked out from the other digits. The scanner recalculates it and rejects a misread if the digits do not match, so the item must be scanned again.

Understanding Bar code check digit in IGCSE Computer Science Paper 1

What it does: A matching check digit means the bar code was probably read correctly, so the scanner accepts it. A mismatch shows the digits were misread, so the scanner rejects them and asks for a rescan. The check digit sits at the end of the number and is worked out from the 12 digits before it. The weights go 1, 3, 1, 3... so the first digit is multiplied by 1 and the second by 3. EAN-13 and ISBN-13 both use alternating 1 and 3 weights to work out the check digit. The rescan action belongs to a failed check (not equal), not to a successful one.

Common mistakes: EAN-13 bar codes use modulus 10, not 11. The check digit is (10 - r) MOD 10. Modulus 11 is used for other check digit schemes. EAN-13 uses weights 1 and 3 alternately, starting with 1 for the first digit. Odd positions get weight 1 and even positions get weight 3, so the line should set w ← 1.

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 179–188) and word search (Modules 168–188).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which digit of an EAN-13 bar code number is the check digit?
The last (13th) digitThe first digit
Matches
weights: 3 3 3 3 3 3 3 3 3 3 3 3
↓
EAN-13 does not use the weight 3 for every digit. The weights alternate 1, 3, 1, 3 and so on, starting with 1.
Applying
Meanings
Term
check digit
Meaning
The last digit of a bar code number, worked out from the other digits. The scanner recalculates it and rejects a misread if the digits do not match, so the item must be scanned again.
Practice
total ← 0
Testing
Gaps
check ← (10 - (total 10)) MOD 10
Check Answer
Spots
2r ← total MOD 10
3check ← (10 - r) MOD 11

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

The 'Flamingo' badge — Balanced Coder, 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. Which digit of an EAN-13 bar code number is the check digit?
A. The first digit
B. The last (13th) digit ✓
The check digit sits at the end of the number and is worked out from the 12 digits before it.
2. What does the scanner do with the check digit?
A. Uses it to look up the price of the item
B. Recalculates it from the other digits and compares it ✓
The scanner repeats the calculation on the first 12 digits. If its answer matches the last digit, the read is accepted.
3. Which weights does EAN-13 use when calculating its check digit?
A. Alternating 1 and 3, the same as ISBN-13 ✓
B. Counting down from 13 to 2
EAN-13 and ISBN-13 both multiply the digits by 1, 3, 1, 3 and so on. The counting-down weights belong to a different check digit method.
4. The scanner recalculates the check digit and it does not match the last digit. What happens?
A. It beeps again or asks for a rescan ✓
B. It adds the item to the till using the closest matching code
A failed check means the number was probably misread, so the item must be scanned again.
5. In an EAN-13 calculation, what weight does the second digit get?
A. 3 ✓
B. 1
The weights go 1, 3, 1, 3... so the first digit is multiplied by 1 and the second by 3.

Match the Pairs

weights: 1 3 1 3 1 3 1 3 1 3 1 3 → The first 12 digits of an EAN-13 bar code are multiplied by alternating weights of 1 and 3, the same pattern as ISBN-13.
(10 - (total MOD 10)) MOD 10 → Turns the weighted total into the check digit. If the total ends in 0, the check digit is 0.
The scanner recalculates the check digit from the first 12 digits and compares it with the 13th digit it read. → IF calculated = digit13 THEN accept
If the recalculated check digit does not match, the scanner rejects the misread and beeps for the item to be scanned again. → IF calculated ≠ digit13 THEN beep and rescan
weights: 3 3 3 3 3 3 3 3 3 3 3 3 → EAN-13 does not use the weight 3 for every digit. The weights alternate 1, 3, 1, 3 and so on, starting with 1.
IF calculated = digit13 THEN rescan → A match means the read passed the check, so the item should be accepted. The scanner should only beep and ask for a rescan when the digits do not match.

Key Term

check digit
The last digit of a bar code number, worked out from the other digits. The scanner recalculates it and rejects a misread if the digits do not match, so the item must be scanned again.

Fill in the Blanks

1. check ← (10 - (total MOD 10)) MOD 10
Hint: Type the operator that gives the remainder after dividing the weighted total by 10.
2. IF position MOD 2 = 0 THEN weight ← 3
Hint: Type the EAN-13 weight used for digits in even positions (the other weight is 1).
3. IF calculated <> lastDigit THEN OUTPUT "Scan again" ENDIF
Hint: Type the comparison operator meaning 'not equal to', so a mismatch rejects the scan.
4. first12 ← LEFT(code, 12) lastDigit ← MID(code, 13, 1)
Hint: Type the position of the check digit within the full bar code number.
5. REPEAT INPUT code UNTIL checkOK = TRUE
Hint: Type the keyword that ends the loop only once the check digit passes, so a failed check means rescanning.

Spot the Error

Question 1
A total ← weighted sum
B r ← total MOD 10
C check ← (10 - r) MOD 11
D PRINT check
Line C — EAN-13 bar codes use modulus 10, not 11. The check digit is (10 - r) MOD 10. Modulus 11 is used for other check digit schemes.
Question 2
A FOR i ← 1 TO 12
B IF i MOD 2 = 1 THEN w ← 3
C ELSE w ← 3
D total ← total + w * d[i]
E NEXT i
Line B — EAN-13 uses weights 1 and 3 alternately, starting with 1 for the first digit. Odd positions get weight 1 and even positions get weight 3, so the line should set w ← 1.
Question 3
A code ← SCAN()
B calc ← CALC(code)
C IF calc = RIGHT(code, 1) THEN
D PRINT "Accepted"
Line B — The scanner must recalculate the check digit from the first 12 digits only. Passing the whole code includes the check digit itself. It should be CALC(LEFT(code, 12)).
Question 4
A check ← RIGHT(code, 1)
B calc ← CALC(LEFT(code, 12))
C IF calc <> check THEN
D OUTPUT "Accepted"
E ENDIF
Line D — When the recalculated digit does not match the check digit, the scan is rejected. The scanner should beep and ask for a rescan, not accept the item.
Question 5
A total ← 1
B FOR i ← 1 TO 12
C total ← total + w * d[i]
D NEXT i
Line A — The running total must start at 0. Starting at 1 adds an extra amount to the weighted sum and gives the wrong check digit.

Student with a class code? Join your class →