Skip to main content
O-LevelComputer ScienceAlgorithm design and problem-solving2210/21 · May/June 2018 · Q38 Marks

The global trade item number (GTIN-8) barcode has seven digits and a check digit. This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the GTIN-8. DIV (X, Y), finds the number of divides in division for example DIV (23,10) is 2. MOD (X, Y), finds the remainder in division for example MOD (23,10) is 3. ``` FOR Count ← 1 TO 7 INPUT Number Digit(Count) ← Number NEXT Sum ← (Digit(1)+Digit(3)+Digit(5)+Digit(7))*3+Digit(2)+Digit(4)+Digit(6) IF MOD(Sum,10) <> 0 THEN Digit(8) ← DIV(Sum,10)*10 + 10 – Sum ELSE Digit(8) ← 0 ENDIF OUTPUT "GTIN-8" FOR Count ← 1 TO 8 OUTPUT Digit(Count) NEXT ```

  1. (a)Complete the trace table for the input data: 5, 7, 0, 1, 2, 3, 4 | Digit(1) | Digit(2) | Digit(3) | Digit(4) | Digit(5) | Digit(6) | Digit(7) | Digit(8) | Sum | OUTPUT | |----------|----------|----------|----------|----------|----------|----------|----------|-----|----------| | 5 | 7 | 0 | 1 | 2 | 3 | 4 | | 44 | GTIN-8 | | | | | | | | | | | 57012346 | Complete the trace table for the input data: 4, 3, 1, 0, 2, 3, 1 | Digit(1) | Digit(2) | Digit(3) | Digit(4) | Digit(5) | Digit(6) | Digit(7) | Digit(8) | Sum | OUTPUT | |----------|----------|----------|----------|----------|----------|----------|----------|-----|----------| | 4 | 3 | 1 | 0 | 2 | 3 | 1 | | 30 | GTIN-8 | | | | | | | | | | | 43102310 |[5]
  2. (b)Explain how you would change the algorithm to input eight digits (seven digits and the check digit) and output if the check digit entered is correct or not.[3]

Mark scheme

Marking points from the official mark scheme (May/June 2018). The mark or mark type is shown in brackets.

  1. [1] (a) One mark for data entry – both sets of digits 1-7
  2. [1] (a) One mark for both Digit(8)
  3. [1] (a) One mark for each Sum (max Two)
  4. [1] (a) One mark for both OUTPUT
  5. [1] (b) Change first loop to 8 iterations
  6. [1] (b) Check that the input Digit (8) is equal to the calculated Digit (8)...
  7. [1] (b) ...if equal output check digit correct
  8. [1] (b) ...otherwise output check digit incorrect
  9. [1] (b) OR Change first loop to 8 iterations
  10. [1] (b) OR Put all 8 digits through the algorithm to calculate Sum
  11. [1] (b) OR ...if MOD(Sum,10) is equal to zero, check digit correct
  12. [1] (b) OR ...otherwise output check digit incorrect

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Algorithm design and problem-solving, O-Level Computer Science (syllabus 2210). Structured question, 8 marks.
Source
O-Level Computer Science, May/June 2018 Paper 2 Variant 1, question 3.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep