Computer Science · Oct / Nov 2022 · Paper 21 · Question 2
0478
As printed in the paper
The question as text
An algorithm has been written to: • set 100 elements of the array Reading[1:100] to zero • input integer values between 1 and 100 • end the process with an input of –1 • reject all other values • count and output the number of times each value is input, starting with the largest value.
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
2(a)[6]
One mark per mark point, max six
Line 1 100Line 7 Value > 100 // Value >= 101Line 11 Reading[Value] + 1Line 14 INPUT ValueLine 18 Reading[Count]Line 19 Count – 12(b)[3]
One mark per mark point, max three
use an IF/conditional statementto check if Reading[Count] not equal to zerobefore outputting the value // between statements 17 and 18 // code sample showing positionIF Reading[Count] <> 0
THEN
OUTPUT
ENDIF
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

