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 (NH) 133470/3
© UCLES 2017 [Turn over
2
1 (a) (i) Procedural high-level languages usually support different data types.
Give an appropriate data type for each data value in the following table.
(ii) State an appropriate data structure to store the individual test scores for a class of
students.
.......................................................................................................................................[1]
(iii) Describe how characters are represented using the ASCII character set.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
Explain why you should use subroutines when designing a program solution.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
IF MyVar = 1
THEN
CALL Proc1()
ELSE
IF MyVar = 2
THEN
CALL Proc2()
ELSE
IF MyVar = 3
THEN
CALL Proc3()
ELSE
OUTPUT "Error"
ENDIF
ENDIF
ENDIF
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
You are given program code written in a high-level language that you have not studied.
State two different features of the code that you should be able to recognise.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
[2]
INPUT StartNumber
INPUT EndNumber
INPUT Divisor
NumberFound 0
For the built-in functions list, refer to the Appendix on page 14.
[3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
[10]
3 (a) A multi-user computer system stores information about users. It uses a 1D array,
UserNameArray, of type STRING. There are 100 elements in the array.
<UserID><UserName>
You should assume that UserNameArray has been declared as a global variable.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
(b) The value of UserID should be unique for each user but a problem has occurred and
repeated UserID values may have been issued.
The array is sorted by UserID, so any repeated UserID values will appear in consecutive
array elements.
This will:
• compare each element with the previous element and output the UserID and UserName
if the UserID is repeated
• output the total number of UserIDs that are repeated.
122222Jim Moriarty
123456Fred Smith
123456Eric Sykes Repeated User ID
123456Kevin Turvey Repeated User ID
222244Alice Chan
222244Myra Singh Repeated User ID
333333Yasmin Halim
123456Eric Sykes
123456Kevin Turvey
222244Myra Singh
There are 3 repeated UserIDs
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]
1 ........................................................................................................................................
2 ........................................................................................................................................
3 ........................................................................................................................................
[3]
...........................................................................................................................................
.......................................................................................................................................[1]
(iii) Name two features provided by an IDE that assist in the program development cycle.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
[2]
(iv) The procedure, FindRepeats, is written assuming there are 100 elements in
UserNameArray.
In the main program, the global array, UserNameArray, has been declared with only
50 elements.
.......................................................................................................................................[1]
4 Numeric formatting converts a numeric value to a string in order to present it in a specific way.
In a generic high-level language, formatting is implemented using a mask system. In this system,
each character of the mask corresponds to one character of the formatted string.
Any other mask characters are taken as literal values and are included in the formatted string.
(a) Using the mask "###00.00", complete the following table. Use □ to represent a space. The
first value has been done for you.
(b) For each row in the following table, define the mask required to produce the formatted output
from the given value. □ represents a space.
5 A sports club maintains a record of the email address of each of its members. The details are
stored in a text file, EmailDetails.txt. The format of each line of the text file is as follows:
<MembershipNumber><EmailAddress>
Membership of the club has increased and a four-character membership number is no longer
adequate.
For the built-in functions list, refer to the Appendix on page 14.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[8]
© UCLES 2017 9608/21/O/N/17
13
(b) A function, IsEmailValid, is to be written to test for a valid email address format.
An email address has a valid format if it obeys the following three rules:
Choose three different invalid strings to test distinct aspects of the rules.
1 ................................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
Appendix
Built-in functions (pseudocode)
In each function, if the function call is not properly formed, the function returns an error.
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings
&
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND on two Boolean values
AND
Example: TRUE AND FALSE produces FALSE
Performs a logical OR on two Boolean values
OR
Example: TRUE OR FALSE produces TRUE
© UCLES 2017 9608/21/O/N/17
15
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.