Past-paper question · 2018 October-November · Paper 21 · Q4(b)

Question 4(b) 2018 · October-November · Paper 21 · 6 marks

Original past-paper question for 4(B)
Original past-paper question for 4(B)
Reveal official mark-scheme answer Official mark-scheme answer for 4(B)

Official answer for Question 4

Part (b)

✓
Pseudocode solution included here for development and clarification of mark

Question 6

✓
scheme.
✓
Programming language solutions appear at the end of this mark scheme.
✓
FUNCTION ScanArray(SearchString : STRING) RETURNS INTEGER
✓
DECLARE ArrayIndex : INTEGER
✓
DECLARE ArrayString : STRING
✓
DECLARE NumberFound : INTEGER
✓
NumberFound ← 0
✓
FOR ArrayIndex ← 1 TO NumElements
✓
ArrayString ← ResultArray[ArrayIndex, 1]
✓
IF TO_UPPER(ArrayString) = TO_UPPER(SearchString)
✓
THEN
✓
CALL SaveToFile(ArrayString)
✓
NumberFound ← NumberFound + 1
✓
ENDIF
✓
ENDFOR
✓
RETURN NumberFound
✓
ENDFUNCTION

Mark scheme 9608_w18_ms_21.pdf →

Show text version of question

Question 4

Part (b)

Question 4

Part of a program written in pseudocode is shown.

01 DECLARE NumElements : INTEGER

…

10 FUNCTION ScanArray(SearchString : STRING) RETURNS INTEGER

Question 11

12 DECLARE ArrayIndex : INTEGER 13 DECLARE ArrayString : STRING 14 DECLARE NumberFound : INTEGER

Question 15

16 ArrayIndex 0 17 NumberFound 0

Question 18

19 FOR ArrayIndex 1 TO NumElements 20 ArrayString ResultArray[ArrayIndex, 1] 21 IF ArrayString = SearchString 22 THEN 23 CALL SaveToFile(ArrayString) 24 NumberFound NumberFound + 1 25 ENDIF 26 ENDFOR

Question 27

28 RETURN NumberFound

Question 29

30 ENDFUNCTION

Part (b)

The function ScanArray() needs to be amended so that the comparison is not case

sensitive. For example, comparing “Aaaa” with “AAAa” should evaluate to TRUE.

Write program code to implement the amended ScanArray() function.

Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.

Programming language ............................................................................................................

Program code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[6]

Question 12

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

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 9608_w18_qp_21.pdf

Keep practising this topic