Past-paper question · 2018 October-November · Paper 22 · Q4(d)

Question 4(d) 2018 · October-November · Paper 22 · 3 marks

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

Official answer for Question 4

Part (d)

✓
Pseudocode solution included here for development and clarification of

Question 3

✓
mark scheme.
✓
Programming language solutions appear at the end of this mark scheme.
✓
DECLARE ResultArray : ARRAY [1:100] OF STRING
✓
DECLARE Index: INTEGER
✓
FOR Index ← 1 TO 100
✓
ResultArray[Index] ← "NO DATA"
✓
ENDFOR
✓
1 mark for each of the following:
✓
•
✓
ResultArray declaration / commented in Python
✓
•
✓
Loop for 100 elements
✓
•
✓
«assignment of string "NO DATA" to indexed array element
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2018
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w18_ms_22.pdf →

Show text version of question

Question 4

Part (d)

Question 4

Part of a program written in pseudocode is shown.

010 DECLARE NextArrayElement : INTEGER

…

100 FUNCTION ScanFile(SearchString: STRING) RETURNS INTEGER 101 102 DECLARE FileData : STRING 103 DECLARE FileLine : INTEGER 104 105 NextArrayElement 1 106 FileLine 1 107 FileData ReadFileLine("DataFile.txt", FileLine) 108 109 WHILE FileData <> "" 110 IF LEFT(FileData, 7) = SearchString 111 THEN 112 ResultArray[NextArrayElement] FileData 113 NextArrayElement NextArrayElement + 1 114 ENDIF 115 FileLine FileLine + 1 116 FileData ReadFileLine("DataFile.txt", FileLine) 117 ENDWHILE 118 119 CALL ScanCompleted() 120 RETURN FileLine 121 122 ENDFUNCTION

Part (d)

ResultArray is a 1D array of type STRING. It contains 100 elements.

Write program code to declare ResultArray and set all elements to the value "NO DATA".

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

Program code

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

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

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

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

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

...............................................................................................................................................[3]

Question 13

Question 5 begins on the next page.

Question 14

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_22.pdf

Keep practising this topic