Past-paper question · 2024 May-June · Paper 21 · Q5(b)(i)

Question 5(b)(i) 2024 · May-June · Paper 21 · 7 marks

Original past-paper question for 5(B)(I)
Original past-paper question for 5(B)(I)
Original past-paper question for 5(B)(I)
Reveal official mark-scheme answer

Official answer for Question 5

Part (b)

(i)

✓
OTHERWISE : CALL Error(C)

Question 1

Mark scheme 9618_s24_ms_21.pdf →

Show text version of question

Question 5

Part (b)

(i)

Question 5

A global 1D array of strings contains three elements which are assigned values as shown:

Data[1] "aaaaaa" Data[2] "bbbbbb" Data[3] "cccccc"

Procedure Process() manipulates the values in the array.

The procedure is written in pseudocode as follows:

PROCEDURE Process(Format : STRING) DECLARE Count, Index, L : INTEGER DECLARE Result : STRING DECLARE C : CHAR

Result "****"

FOR Count 1 TO LENGTH(Format) STEP 2

C
MID(Format, Count, 1)

L STR_TO_NUM(MID(Format, Count + 1, 1))

Index (Count + 1) DIV 2

CASE OF C 'X' : Result TO_UPPER(Data[Index]) 'Y' : Result TO_LOWER(Data[Index]) 'Z' : Result "**" & Data[Index] ENDCASE

Data[Index] LEFT(Result, L) NEXT Count

ENDPROCEDURE

Question 11

The procedure is to be modified. If variable C is assigned a value other than 'X', 'Y' or 'Z', then procedure Error() is called and passed the value of variable C as a parameter.

This modification can be implemented by adding a single line of pseudocode.

(i)

Write the single line of pseudocode.

.....................................................................................................................................

[1]
Topic relevance

Why this question appears here

72% assigned-topic match · Data types and structures › Data types and records

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9618_s24_qp_21.pdf

Keep practising this topic