Past-paper question · 2019 October-November · Paper 23 · Q4(b)(i)

Question 4(b)(i) 2019 · October-November · Paper 23 · 5 marks

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

Official answer for Question 4

Part (b)

(i)

✓
One mark for each area as outlined:

Question 5

✓
Index
✓
NextChar
✓
NumDots
✓
NumAts
✓
NumOthers
✓
0
✓
0
✓
0

Question 1

✓
'J'

Question 1

Question 2

✓
'i'

Question 2

Question 3

✓
'm'

Question 3

Question 4

✓
'.'

Question 1

Question 5

✓
'9'

Question 4

Question 6

✓
'9'

Question 5

Question 7

✓
'@'

Question 1

Question 8

✓
's'

Question 6

Question 9

✓
'k'

Question 7

Question 10

✓
'a'

Question 8

Question 11

✓
'i'

Question 9

Question 12

✓
'l'

Question 10

Question 13

✓
'.'

Question 2

Question 14

✓
'c'

Question 11

Question 15

✓
'o'

Question 12

Question 16

✓
'm'

Question 13

Mark scheme 9608_w19_ms_23.pdf →

Show text version of question

Question 4

Part (b)

(i)

Question 4

The following pseudocode algorithm checks whether a string is a valid email address.

FUNCTION Check(InString : STRING) RETURNS BOOLEAN

DECLARE Index : INTEGER DECLARE NumDots : INTEGER DECLARE NumAts : INTEGER DECLARE NextChar : CHAR DECLARE NumOthers : INTEGER

NumDots 0 NumAts 0 NumOthers 0

FOR Index 1 TO LENGTH(InString)

NextChar MID(InString, Index, 1) CASE OF NextChar '.': NumDots NumDots + 1 '@': NumAts NumAts + 1 OTHERWISE NumOthers NumOthers + 1 ENDCASE

ENDFOR

IF (NumDots >= 1 AND NumAts = 1 AND NumOthers > 5) THEN RETURN TRUE ELSE RETURN FALSE ENDIF

ENDFUNCTION

(i)

Complete the trace table by dry running the function when it is called as follows:

Result Check("Jim.99@skail.com")

Index NextChar NumDots NumAts NumOthers

[5]
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 9608_w19_qp_23.pdf

Keep practising this topic