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 (LK/CGW) 146140/3
© UCLES 2018 [Turn over
2
Variable Value
MyGreeting "Happy Birthday"
MyInitial 'C'
AgeInYears 27
Weight 60.5
Married TRUE
Children TRUE
For the built-in functions list, refer to the Appendix on page 15.
Expression Evaluates to
"Mon" & MID(MyGreeting, 10, 2)
AgeInYears + ASC(MyInitial)
INT(MyInitial)
MOD(Weight * 2, 10)
Married AND (NOT Children)
[5]
Give an appropriate data type for each of these variables from part (b)(i).
(a) (i) This pseudocode includes features that make it easier to read and understand.
Feature 1 ...........................................................................................................................
Feature 2 ...........................................................................................................................
Feature 3 ...........................................................................................................................
Feature 4 ...........................................................................................................................
[4]
(ii) State one feature that could be added to make the pseudocode easier to understand.
.......................................................................................................................................[1]
(b) Study the function StringClean(). Identify the features of the function in the following
table.
Feature Answer
In the factory:
The procedure CheckSensor() will compare the measured temperature against each of two
constant values, LowTemp and HighTemp. It will perform the following actions depending on the
result of the comparison.
A library function, GetTemp(), returns the temperature value from a given sensor.
The structured English representing the algorithm for the procedure CheckSensor() is as
follows:
Draw a program flowchart on the next page to represent the algorithm for procedure
CheckSensor().
[8]
© UCLES 2018 9608/21/M/J/18 [Turn over
8
Iteration and selection are two features of an algorithm that may be shown on a structure chart.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
Feature 3 ..................................................................................................................................
...................................................................................................................................................
[3]
IF AddItem = "Yes"
THEN
RetFlag AddToList(InString)
ELSE
CALL RemoveFromList(InString)
ENDIF
RETURN RetFlag
ENDFUNCTION
[6]
5 A golf club holds information about its members. When a member completes a round of golf, their
score is stored along with their membership number and the date of the round.
(a) Explain why the club stores these data in a file rather than an array.
...................................................................................................................................................
...............................................................................................................................................[1]
(b) Editing functions such as cut, copy and paste are features provided by an Integrated
Development Environment (IDE).
Give two additional features of an IDE that are helpful when coding a program.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
[2]
(c) The information is stored in a text file, ScoreDetails.txt. The format of each line of the
text file is as follows:
<MembershipNumber><Date><Score>
A procedure, AddNewScores(), is being developed. This will allow the user to enter scores
for several members on a particular date.
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
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
......................................................................................................................................................[9]
© UCLES 2018 9608/21/M/J/18 [Turn over
12
n 3
x StudentGrade[n]
(i) Use the correct technical terms to explain the meaning of [1:5] in this pseudocode.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(ii) Use the correct technical term to complete the following statement.
(b) A 2D array, Picture, contains data representing a bitmap image. Each element of the array
represents one pixel of the image. The image is grey-scale encoded where the value of each
pixel ranges from 0 (representing black) to 255 (representing white) with intermediate values
representing different levels of grey.
The following is an example of an image and the corresponding data values for the Picture
array.
240 10 10 10 10 10 10 240
80 80 240 80 80 240 80 80
80 80 240 80 80 240 80 80
A function, Lighten(), is required to lighten the image. Lightening an image may cause it to
‘burn out’. An image is said to be ‘burnt out’ if any pixel is set to the maximum value of 255.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
......................................................................................................................................................[8]
© UCLES 2018 9608/21/M/J/18 [Turn over
14
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
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
......................................................................................................................................................[7]
© UCLES 2018 9608/21/M/J/18
15
Appendix
Built-in functions (pseudocode)
Each function returns an error if the function call is not properly formed.
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
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.