Question 4(a) 2021 · May-June · Paper 23 · 5 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (a)
Question 5
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
Question 7
Question 8
Question 9
Question 10
Question 11
- One mark for each of columns 2 to 5 (condone missing final 11)
- One mark for final row all correct (including final 11)
Show text version of question
Question 4
Part (a)
Question 4
Study the following pseudocode. Line numbers are for reference only.
10 FUNCTION Convert(Name : STRING) RETURNS STRING
Question 11
12 DECLARE Flag: BOOLEAN 13 DECLARE Index : INTEGER 14 DECLARE ThisChar : CHAR 15 DECLARE NewName : STRING
Question 16
17 CONSTANT SPACECHAR = ' '
Question 18
19 Flag TRUE 20 Index 1 21 NewName "" // formatted name string
Question 22
23 WHILE Index <= LENGTH(Name) 24 ThisChar MID(Name, Index, 1) 25 IF Flag = TRUE THEN 26 NewName NewName & UCASE(ThisChar) 27 IF ThisChar <> SPACECHAR THEN 28 Flag FALSE 29 ENDIF 30 ELSE 31 NewName NewName & ThisChar 32 ENDIF 33 IF ThisChar = SPACECHAR THEN 34 Flag TRUE 35 ENDIF 36 Index Index + 1 37 ENDWHILE
Question 38
39 RETURN NewName
Question 40
41 ENDFUNCTION
Question 11
Part (a)
Complete the trace table below by dry running the function when it is called as follows:
Result Convert("∇in∇a∇∇Cup")
Note: The symbol '∇' has been used to represent a space character. Use this symbol for any space characters in the trace table.
The first row has been completed for you.
Name Flag Index NewName ThisChar
"∇in∇a∇∇Cup"
Question 12
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 9618_s21_qp_23.pdf
