Note AcademyNote Academy

Computer Science · May / June 2023 · Paper 22 · Question 11

0478

As printed in the paper

The question as text

The variables P and Q are used to store data in a program. P stores a string. Q stores a character.

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

Show the answer and mark scheme
  • 11(a)[2]

    One mark for any two correct lines

    DECLARE P : STRING

    P ← "The world"

    DECLARE Q : CHAR

    Q ← 'W'

  • 11(b)[4]

    One mark for each point (max four)

    converting P to upper case
    finding the length of P
    using a loop to check for position of Q
    using the string operation substring
    storing the loop counter in Position if the value is found

    For example:

    P ← UCASE(P)

    Counter ← 1

    Position ← 0

    REPEAT

    IF SUBSTRING(P, Counter, 1) = Q

    THEN

    Position ← Counter

    ENDIF

    Counter ← Counter + 1

    UNTIL Position <> 0 OR Counter = LENGTH(P)

  • 11(c)[1]

    5

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