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 (NH/CT) 151783/3
© UCLES 2018 [Turn over
2
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.
Repetition
Statement Assignment Selection
(Iteration)
CASE OF TempSensor1
ELSE
REPEAT
ENDFOR
DayNumber DayNumber + 1
Error TRUE
[6]
Give the most appropriate data type for the variable used in each statement.
Complete the table by evaluating each expression using the values from part (b)(i).
For the built-in functions list, refer to the Appendix on page 16.
Expression Evaluates to
"Month: " & MID(ModelRef, 5, 3)
INT(MinValue * 2)
ASC(Revision)
Revision > 500
ServiceDue = TRUE OR FuelType = 'P'
[5]
2 Shop customers have a discount card with a unique card number. Customers collect points when
they buy items. At the end of each year, customers are given bonus (extra) points related to the
total amount they have spent during the year, and the number of points they have on their card.
The function CalcBonus() takes the card number as a parameter. It returns the bonus points for
the customer. A flowchart for the function is shown.
START
Points
GetPoints(CardNum)
Spend
GetSpend(CardNum)
Is YES
Points > 2000 ?
NO
Is YES
Spend > 1000 ?
NO
RETURN Bonus
END
Your solution should follow the flowchart for the function as closely as possible.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
(ii) The function GetCardNumber() prompts the user to input a card number until the
number input is valid.
A valid card number has 16 characters. Each character is a numeric character ('0' to
'9').
You should refer to the function IS_NUM() in the Appendix on page 16.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
ENDFUNCTION
[6]
© UCLES 2018 9608/23/O/N/18
7
(i) The function is tested using black-box testing and does not contain any syntax errors.
Name and describe one other type of error that black-box testing could find.
Name .................................................................................................................................
Description ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
State two different pairs of values for Spend and Points that can be used to test
different paths through the function. Justify your choices.
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[4]
(c) Name two types of program maintenance and state the reason why each is needed.
Name ........................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Name ........................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[4]
3 An array contains 100 integer values. An algorithm will find the maximum and minimum values
stored in the array.
(a) A programmer has started to write this program using a conditional loop.
Name a more appropriate loop structure for this task and justify your choice.
Name ........................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(b) Outline the steps the program will need to follow to implement the algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
…
100 FUNCTION Update(NewData : STRING) RETURNS INTEGER
101 DECLARE ArrayIndex : INTEGER
102 DECLARE Found : BOOLEAN
103
104 ArrayIndex 1
105 Found FALSE
106
107 WHILE ArrayIndex <= LastElement AND Found = FALSE
108 IF ThisArray[ArrayIndex, 1] > NewData
109 THEN
110 Found TRUE
111 ELSE
112 ArrayIndex ArrayIndex + 1
113 ENDIF
114 ENDWHILE
115
116 IF Found = TRUE
117 THEN
118 CALL Insert(ArrayIndex, NewData)
119 ELSE
120 ArrayIndex 0
121 ENDIF
122
123 RETURN ArrayIndex
124 ENDFUNCTION
(a) (i) Examine the pseudocode and complete the following table.
Answer
The name of a global identifier
The name of a user-defined procedure
The scope of ArrayIndex
The number of dimensions of ThisArray
The scope of NewData
[5]
(ii) Describe in detail, the purpose of lines 107 to 114 in the Update() function.
Do not use pseudocode in your answer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
© UCLES 2018 9608/23/O/N/18
11
(b) Line 118 of the function Update() calls the subroutine Insert(). A designer decides to
convert Insert() from a procedure to a function. Insert() returns TRUE or FALSE.
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]
© UCLES 2018 9608/23/O/N/18 [Turn over
12
Describe the mechanism that supports the transfer of values between modules.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
Write program code to change all the numeric characters ('0' to '9') in CharArray
to '*'.
Program code
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[3]
.......................................................................................................................................[1]
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
....................................................................................................................................................[10]
© UCLES 2018 9608/23/O/N/18 [Turn over
16
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
© UCLES 2018 9608/23/O/N/18