Cambridge International Advanced Subsidiary and Advanced Level
Cambridge International Advanced Subsidiary and Advanced Level
Cambridge International Advanced Subsidiary and Advanced Level
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (NF) 129956/4
© UCLES 2017 [Turn over
2
2 DISPLAY RIGHT(String1, 5)
[6]
Variable Value
FlagA TRUE
FlagB FALSE
FlagC TRUE
Expression Evaluates to
[3]
(c) The loop construct (also known as repetition or iteration) appears in many algorithms.
Use pseudocode to write a post-condition loop to output all the odd numbers between 100
and 200.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [4]
2 A multi-user computer system maintains a text file containing the ID and preferred name for each
user.
User IDs are unique. Preferred names may be repeated.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [2]
(b) An initial identifier table is created as part of the stepwise refinement. A section of the table is
shown. Complete this table.
...........................................................................
FileUserID
...........................................................................
...........................................................................
FilePreferredName
...........................................................................
...........................................................................
IDFoundFlag
...........................................................................
[5]
(c) The file may not contain an entry for every user. If the user ID is not found, then the name
“Guest” should be used as the preferred name.
Use structured English to write a more detailed algorithm for the welcome message process
described in part (a).
Assume that the file, UserNames.txt, is organised as a simple text file. The user ID and
preferred name are held together in unencrypted form, one entry per line.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [8]
This function forms a return string, OutString, from a given string, InString, by:
1 separating the original words (a word is assumed to start with a capital letter)
2 converting all characters to lower case.
The following shows a pair of example values for the string values InString and OutString.
InString : "MyUserInput"
OutString : "my user input"
You may assume that InString always starts with a capital letter.
The following is a first attempt at writing the pseudocode for this function.
For the built-in functions list, refer to the Appendix on page 13.
DECLARE n: INTEGER
THEN
THEN
ENDIF
ENDIF
ENDFOR
ENDFUNCTION
[11]
4 (a) High-level programming languages have many features that support the modular approach.
One such feature is the use of parameters.
1 ...............................................................................................................................................
...................................................................................................................................................
2 ...............................................................................................................................................
...................................................................................................................................................
[2]
PROCEDURE MyProc(x)
x x + 1
ENDPROCEDURE
x 4
CALL MyProc(x)
OUTPUT(x)
......................................................................................
.................................
............. ......................................................................................
.................................
......................................................................................
......................................................................................
.................................
............. ......................................................................................
.................................
......................................................................................
[6]
5 A multi-user computer system records user login data. Each time a user successfully logs into the
system, it records the following data.
User ID "Jim27"
Port ID "3456"
The data items are concatenated (joined) using a separator character to form a single string. Each
string represents one log entry.
(a) (i) Suggest a suitable separator character. Give the reason for your choice.
Character ..........................................................................................................................
Reason ..............................................................................................................................
...........................................................................................................................................
[2]
(ii) The concatenated strings are stored in an array, LogArray, which may contain up to 20
log entries.
...................................................................................................................................... [2]
(b) A procedure, LogEvents, is required to add the log entry data from LogArray to the existing
text file, LoginFile.txt.
Unused array elements are assigned the value "****". These can occur anywhere in the
array and should not be written to the file.
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [8]
6 A computerised vehicle licensing system stores details about vehicles and their registration marks
(number plates or license plates).
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2017 9608/22/M/J/17
11
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [9]
Give a valid string that could be used to check that the function returns TRUE under the
correct conditions.
String1: .....................................................................................................................................
String2: .....................................................................................................................................
Explanation: ..............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
String3: .....................................................................................................................................
Explanation: ..............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
String4: .....................................................................................................................................
Explanation: ..............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
String5: .....................................................................................................................................
Explanation: ..............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[5]
Appendix
returns the character value representing the lower case equivalent of ThisChar.
If ThisChar is not an upper case alphabetic character then it is returned unchanged.
Example: LCASE('W') returns 'w'
returns the character value representing the upper case equivalent of ThisChar.
If ThisChar is not a lower case alphabetic character then it is returned unchanged.
Example: UCASE('h') returns 'H'
returns the integer value representing the remainder when ThisNum is divided by ThisDiv.
Example: MOD(10,3) returns 1
returns the integer value representing the whole number part of the result when ThisNum is
divided by ThisDiv.
Example: DIV(10,3) returns 3
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings
&
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND of two Boolean values
AND
Example: TRUE AND FALSE produces FALSE
Performs a logical OR of two Boolean values
OR
Example: TRUE OR FALSE produces TRUE
© UCLES 2017 9608/22/M/J/17
14
BLANK PAGE
BLANK PAGE
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.