Note AcademyNote Academy

Computer Science · Oct / Nov 2016 · Paper 22 · Question 2

2210

As printed in the paper

The question as text

Read this section of program code that inputs positive numbers, discards any negative numbers and then outputs the average. An input of zero ends the process. 1 Total = 0 2 Counter = 100 3 REPEAT 4 REPEAT 5 INPUT Num 6 UNTIL Num < 0 7 Total = Total + 1 8 Counter = Counter + Num 9 UNTIL Num = 0 10 Average = Total / (Counter - 1) 11 Print Average There are four errors in this code. Locate these errors and suggest a correction to remove each error. Error 1 Correction Error 2 Correction Error 3 Correction Error 4 Correction [8]

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme

1 mark for identifying each error, 1 mark for the corresponding change – line 2 or Counter = 100 – Counter = 0 – line 6 or UNTIL Num < 0 – UNTIL Num >= 0 – line 7 or Total = Total + 1 – Total = Total + Num – line 8 or Counter = Counter + Num – Counter = Counter + 1 [8]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.