Skip to main content
O-LevelComputer ScienceAlgorithm design and problem-solving2210/22 · May/June 2023 · Q710 Marks

An algorithm has been written in pseudocode to calculate a check digit for a four-digit number. The algorithm then outputs the five-digit number including the check digit. The algorithm stops when -1 is input as the fourth digit. 01 Flag ← FALSE 02 REPEAT 03 Total ← 0 04 FOR Counter ← 1 TO 4 05 OUTPUT "Enter a digit ", Counter 06 INPUT Number[Counter] 07 Total ← Total + Number * Counter 08 IF Number[Counter] = 0 09 THEN 10 Flag ← TRUE 11 ENDIF 12 NEXT Counter 13 IF NOT Flag 14 THEN 15 Number[5] ← MOD(Total, 10) 16 FOR Counter ← 0 TO 5 17 OUTPUT Number[Counter] 18 NEXT 19 ENDIF 20 UNTIL Flag

  1. (a)Give the line number(s) for the statements showing: Totalling Count-controlled loop Post-condition loop[3]
  2. (b)Identify the three errors in the pseudocode and suggest a correction for each error. Error 1 Correction Error 2 Correction Error 3 Correction[3]
  3. (c)The algorithm does not check that each input is a single digit. Identify the place in the algorithm where this check should occur. Write pseudocode for this check. Your pseudocode must make sure that the input is a single digit and checks for -1 Place in algorithm Pseudocode[4]

Mark scheme

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

  1. [3] • 07 • 04/12 or 16/18 • 02/20
  2. [3] One mark for each error identified and correction • Line 07 Total ← Total + Number * Counter should be Total ← Total + Number[Counter] * Counter • Line 08 IF Number[Counter] = 0 should be IF Number[Counter] = -1 // should be IF Number[Counter] < 0 • Line 16 FOR Counter ← 0 TO 5 should be FOR Counter ← 1 TO 5
  3. [4] One mark for place in algorithm (max one) • around lines 05 and 06 • line 07 • (immediately) after the input of the number Three marks pseudocode One mark for each point (max three) • Use of REPEAT ... UNTIL // any working loop structure • check for >0 // >=0 • check for <10 // >9 • check for whole number • check for -1 • check for length of digit <> 1 Example REPEAT OUTPUT "Enter a digit " INPUT Number[Counter] UNTIL Number[Counter] = Round(Number[Counter],0) AND ((Number[Counter] = -1) OR (Number[Counter] > 0 AND Number[Counter] < 10))

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, 10 marks.
Source
O-Level Computer Science, May/June 2023 Paper 2 Variant 2, question 7.

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