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

Question 4(c) 2019 · October-November · Paper 23 · 4 marks

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

Official answer for Question 4

Part (c)

✓
One mark for string and one mark for correct explanation.

Question 4

✓
Same for second answer providing it results in a different path through the
✓
algorithm.
✓
Correct answers may be:
✓
•
✓
without the correct number of '.'
✓
•
✓
without the correct number of '@'
✓
•
✓
without the correct number of 'other characters'
✓
9608/23
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2019
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_23.pdf →

Show text version of question

Question 4

Part (c)

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

Part (c)

The function Check() is to be tested.

State two different invalid string values that could be used to test the algorithm. Each string should test a different rule.

Justify your choices.

Value .........................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Value .........................................................................................................................................

Justification ...............................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

[4]
Topic relevance

Why this question appears here

91% assigned-topic match · Data types and structures › Data types and records

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