Question 4(b)(i) 2019 · October-November · Paper 23 · 5 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (b)
(i)
Question 5
Question 1
Question 1
Question 2
Question 2
Question 3
Question 3
Question 4
Question 1
Question 5
Question 4
Question 6
Question 5
Question 7
Question 1
Question 8
Question 6
Question 9
Question 7
Question 10
Question 8
Question 11
Question 9
Question 12
Question 10
Question 13
Question 2
Question 14
Question 11
Question 15
Question 12
Question 16
Question 13
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
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
