Question 4(b) 2018 · October-November · Paper 21 · 6 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (b)
Question 6
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
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
