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

This pseudocode algorithm is intended to allow, at random, between 1 and 20 values to be entered and totalled. The total and average of the entered values are output at the end of the algorithm. 01 DECLARE Loop : STRING 02 DECLARE Limit : INTEGER 03 DECLARE Value : REAL 04 DECLARE Total : REAL 05 Total ← 0 06 Limit ← ROUND(RANDOM() * 19,0) + 1 07 IF Loop ← 1 TO Limit 08 OUTPUT "Enter a number" 09 INPUT Loop 10 Total ← Total * Value 11 NEXT Loop 12 OUTPUT "The total of the numbers entered is ", Total 13 OUTPUT "The average of the numbers entered is ", Total / Limit

  1. (a)Identify the line numbers of four errors in the pseudocode and suggest corrections. Error 1 line number Correction Error 2 line number Correction Error 3 line number Correction Error 4 line number Correction[4]
  2. (b)Write the pseudocode statement that would output the average calculated in line 13 of the algorithm rounded to one decimal place.[2]
  3. (c)Explain how you should alter the original corrected algorithm to make sure that all the numbers entered are between 1 and 500 inclusive. If any numbers fall outside these limits, a replacement value is requested and entered. You do not need to re-write the algorithm.[4]

Mark scheme

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

  1. [4] (a) One mark per mark point • Line 01 / DECLARE Loop : STRING should be DECLARE Loop : INTEGER • Line 07/ IF Loop ← 1 TO Limit should be FOR Loop ← 1 TO Limit • Line 09 / INPUT Loop should be INPUT Value • Line 10/Total ← Total * Value should be Total ← Total + Value Correct algorithm: 01 DECLARE Loop : INTEGER 02 DECLARE Limit : INTEGER 03 DECLARE Value : REAL 04 DECLARE Total : REAL 05 Total ← 0 06 Limit ← ROUND(RANDOM() * 19,0) + 1 07 FOR Loop ← 1 TO Limit 08 OUTPUT "Enter a number" 09 INPUT Value 10 Total ← Total + Value 11 NEXT Loop 12 OUTPUT "The total of the numbers entered is ", Total 13 OUTPUT "The average number entered is ", Total / Limit
  2. [2] (b) One mark per mark point • Correct use of ROUND with 2 arguments separated by comma, for example ROUND( 5, 2) (in statement 13) ... • (Total / Limit,1) correct arguments For example: OUTPUT "The average of the numbers entered is ", ROUND (Total / Limit,1)
  3. [4] (c) One mark per mark point, max four • After line 09 / after the input • Insert a WHILE / pre-condition loop... • to check if the value entered is between 1 and 500 inclusive If the value is not in range, output an error message • and insert another input statement for re-input. Or • Before line 08 / before the input message start a REPEAT / post-condition loop After line 09 / after the input close the REPEAT loop by checking if the value entered was between 1 and 500 inclusive If it wasn't, (the loop will repeat) for the number to be re-input / If it was, the program continues.

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 2024 Paper 2 Variant 1, question 4.

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