Question 5(b)(i) 2019 · October-November · Paper 21 · 5 marks
Reveal official mark-scheme answer
Official answer for Question 5
Part (b)
(i)
Question 5
Question 1
Question 1
Question 2
Question 1
Question 3
Question 2
Question 4
Question 1
Question 5
Question 2
Question 6
Question 3
Question 7
Question 4
Question 8
Question 5
Question 9
Question 6
Question 10
Question 2
Question 11
Question 1
Question 12
Question 2
Show text version of question
Question 5
Part (b)
(i)
Question 5
The following pseudocode checks whether a string is a valid password.
FUNCTION CheckPassword(InString : STRING) RETURNS BOOLEAN
DECLARE Index, Upper, Lower, Digit, Other : INTEGER DECLARE NextChar : CHAR
Upper 0 Lower 0 Digit 0 Other 0
FOR Index 1 TO LENGTH(InString)
NextChar MID(InString, Index, 1) IF NextChar >= 'A' AND NextChar <= 'Z' THEN Upper Upper + 1 ELSE IF NextChar >= 'a' AND NextChar <= 'z' THEN Lower Lower + 1 ELSE IF NextChar >= '0' AND NextChar <= '9' THEN Digit Digit + 1 ELSE Other Other + 1 ENDIF ENDIF ENDIF
ENDFOR
IF Upper > 1 AND Lower >= 5 AND (Digit - Other) > 0 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 CheckPassword("Jim+Smith*99")
Index NextChar Upper Lower Digit Other
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_21.pdf
