Past-paper question · 2021 May-June · Paper 23 · Q4(a)

Question 4(a) 2021 · May-June · Paper 23 · 5 marks

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

Official answer for Question 4

Part (a)

Question 5

✓
Name
✓
Flag
✓
Index
✓
NewName
✓
ThisChar
✓
"∇in∇a∇∇Cup"
✓
TRUE

Question 1

✓
""
✓
'∇'
✓
"∇"

Question 2

✓
'i'
✓
FALSE
✓
"∇I"

Question 3

✓
'n'
✓
"∇In"

Question 4

✓
'∇'
✓
TRUE
✓
"∇In∇"

Question 5

✓
'a'
✓
FALSE
✓
"∇In∇A"

Question 6

✓
'∇'
✓
TRUE
✓
"∇In∇A∇"

Question 7

✓
'∇'
✓
"∇In∇A∇∇"

Question 8

✓
'C'
✓
FALSE
✓
"∇In∇A∇∇C"

Question 9

✓
'u'
✓
"∇In∇A∇∇Cu"

Question 10

✓
'p'
✓
"∇In∇A∇∇Cup"
✓
FALSE

Question 11

✓
'p'
✓
"∇In∇A∇∇Cup"
✓
Mark as follows:
  • One mark for each of columns 2 to 5 (condone missing final 11)
  • One mark for final row all correct (including final 11)
✓
9618/23
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s21_ms_23.pdf →

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"

[5]

Question 12

Topic relevance

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

Keep practising this topic