Question 4(a)(i) 2021 · May-June · Paper 23 · 5 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (a)
(i)
Question 5
Question 1
Question 1
Question 1
Question 2
Question 2
Question 3
Question 3
Question 4
Question 4
Question 5
Question 2
Question 5
Question 6
Question 6
Question 7
Question 7
Question 8
Question 9
Question 3
Question 8
Question 10
- 1
Question 11
Question 12
Show text version of question
Question 4
Part (a)
(i)
Question 4
Study the following pseudocode for a string handling function Check().
Refer to the Appendix on pages 22 and 23 for the list of built-in pseudocode functions and operators.
FUNCTION Check(InString : STRING) RETURNS INTEGER
DECLARE Index, Result, Count : INTEGER DECLARE NextChar : CHAR
Result 0 Count 1
FOR Index 1 TO LENGTH(InString)
NextChar MID(InString, Index, 1) IF (NextChar >= '0' AND NextChar <= '9') OR NextChar = '.' THEN Result Result + 1 ELSE IF NextChar = ',' THEN Count Count + 1 ELSE Result -1 ENDIF ENDIF ENDFOR
IF Count < 3 THEN RETURN -1 ELSE RETURN Result ENDIF
ENDFUNCTION
Question 9
(i)
Complete the trace table by performing a dry run of the function when it is called as
follows:
Answer Check("74.0,4.6,3x2")
Note, there are no space characters in the string shown.
Result Count Index NextChar
Why this question appears here
71% assigned-topic match · Software development › Program testing and maintenance
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_s21_qp_23.pdf
