Past-paper question · 2014 October-November · Paper 21 · Q2(b)

Question 2(b) 2014 · October-November · Paper 21 · 8 marks

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

Official answer for Question 2

Part (b)

Part (b)

FUNCTION FindPassword(ThisUserID : STRING) RETURNS STRING

✓
// 1 mark
✓
DECLARE Found : BOOLEAN
✓
OPENFILE FOR INPUT
✓
Found FALSE
✓
WHILE NOT EOF AND Found = FALSE
✓
// 2 marks
✓
FILEREAD next record
✓
IF UserID = ThisUserID
✓
// 1 mark
✓
THEN
✓
Found TRUE
✓
// 1 mark
✓
ENDIF
✓
ENDWHILE
✓
IF Found = TRUE
✓
// 1 mark
✓
THEN
✓
RETURN EncryptedPassword
✓
// 1 mark
✓
ELSE
✓
RETURN Error code
✓
// 1 mark
✓
ENDIF
✓
CLOSEFILE
✓
ENDFUNCTION
[8]
✓
Alternative part:
✓
IF Found = False
✓
// 1 mark
✓
THEN
✓
RETURN Error code
✓
// 1 mark
✓
ELSE
✓
RETURN EncryptedPassword
✓
// 1 mark
✓
ENDIF
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – October/November 2014
✓
9691

Question 21

Mark scheme 9691_w14_ms_21.pdf →

Show text version of question

Question 2

Part (b)

Question 2

Ali sets up user IDs and passwords for his program. When the user types in their user ID, the program looks up the stored password for this user ID. The stored password is the encrypted version of the user’s password.

Part (b)

Ali uses a sequential file of records to store the user IDs and encrypted passwords.

When a user types in their User ID, the program calls a function, FindPassword, with parameter ThisUserID. The function searches each record in the file for ThisUserID and returns the encrypted password. If ThisUserID is not stored in the file, the function returns an error code. Complete the pseudocode: FUNCTION FindPassword(ThisUserID : STRING) RETURNS ................. DECLARE Found : BOOLEAN OPENFILE FOR INPUT // for reading Found ← FALSE WHILE ........................................................... FILEREAD next record IF ............................................................ THEN ......................................................... ENDIF ENDWHILE IF .............................................................. THEN ........................................................... ELSE ........................................................... ENDIF CLOSEFILE ENDFUNCTION

[8]

Question 8

Topic relevance

Why this question appears here

72% 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 9691_w14_qp_21.pdf

Keep practising this topic