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

3 This pseudocode algorithm inputs two non-zero numbers and a sign, and then performs the calculation shown by the sign. An input of zero for the first number terminates the process. INPUT Number1, Number2, Sign WHILE Number1 <> 0 IF Sign = '+' THEN Answer ← Number1 + Number2 ENDIF IF Sign = '-' THEN Answer ← Number1 - Number2 ENDIF IF Sign = '*' THEN Answer ← Number1 * Number2 ENDIF IF Sign = '/' THEN Answer ← Number1 / Number2 ENDIF IF Sign <> '/' AND Sign <> '*' AND Sign <> '-' AND Sign <> '+' THEN Answer ← 0 ENDIF IF Answer <> 0 THEN OUTPUT Answer ENDIF INPUT Number1, Number2, Sign ENDWHILE

  1. (a)Complete the trace table for the input data: 5, 7, +, 6, 2, −, 4, 3, *, 7, 8, ?, 0, 0, / Number1 | Number2 | Sign | Answer | OUTPUT[3]
  2. (b)Show how you could improve the algorithm written in pseudocode by writing an alternative type of conditional statement in pseudocode.[3]

Mark scheme

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

  1. [3] Number1 Number2 Sign Answer OUTPUT
  2. 5 7 + 12 12
  3. 6 2 - 4 4
  4. 4 3 * 12 12
  5. 7 8 ? 0
  6. 0 0 / (0)
  7. ← 1 mark → ← 1 mark →
  8. [3] CASE Sign OF ... ENDCASE (1)
  9. List +, -, *, / with correct assignments (1)
  10. OTHERWISE Answer ← 0 (1)
  11. Example CASE Sign OF '+': Answer ← Number1 + Number2 '-': Answer ← Number1 - Number2 '*': Answer ← Number1 * Number2 '/': Answer ← Number1 / Number2 OTHERWISE Answer ← 0 ENDCASE

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