Note AcademyNote Academy

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 100
    Line 7 Value > 100 // Value >= 101
    Line 11 Reading[Value] + 1
    Line 14 INPUT Value
    Line 18 Reading[Count]
    Line 19 Count – 1
  • 2(b)[3]

    One mark per mark point, max three

    use an IF/conditional statement
    to check if Reading[Count] not equal to zero
    before outputting the value // between statements 17 and 18 // code sample showing position

    IF 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.