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) 150983/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 Selection Assignment
(Iteration)
Index Index + 5
FOR Count 1 TO 100
TempValue[Index] ReadValue(SensorID)
IF Index < 30
UNTIL DayNumber > 7
OTHERWISE OUTPUT "ERROR"
[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).
If any expression is invalid, write “ERROR” in the Evaluates to column.
For the built-in functions list, refer to the Appendix on page 16.
Expression Evaluates to
MID(Activity, 3, 4) & "ature"
INT(MaxValue * 2)
ArrayFull AND NumberOfEdits < 300
ASC(Revision + 1)
Activity = "Testing" OR Revision = 'A'
[5]
2 Shop customers have a discount card with a unique card number. Customers collect points each
time they buy items. The number of points they collect depends on:
The function CalcPoints() takes the card number and the total amount spent as parameters. It
returns the number of new points collected. A flowchart for the function is shown.
START
Is YES
Total > 100 ?
OldPoints
NO GetPoints(CardNum)
Is NO
OldPoints > 2000 ?
YES
RETURN NewPoints
END
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[7]
(ii) The value of the total amount spent is calculated by an Electronic Point Of Sale (EPOS)
system. This system does not have the prices of all items. For these items, a valid total
amount has to be entered manually.
If the user enters a valid value greater than 0 and less than 10 000, the function returns
the value. The function prompts the user to re-enter the value each time the user enters
an invalid value.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
ENDFUNCTION
[5]
(b) The function CalcPoints() is written in a high-level language. It has been checked and it
does not contain any syntax or logic errors.
(i) Name and describe one other type of error that the high-level language code could
contain.
Name .................................................................................................................................
Description ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
State two different values of Total that could be used to test different paths through the
algorithm. Justify your choices.
Value .................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Value .................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[4]
You are asked to work on a program written in a language you are not familiar with.
Explain how transferable skills would help you work on the program.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[2]
(c) A program needs to search through 1000 elements of an unsorted array to find a given value.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[4]
© UCLES 2018 9608/22/O/N/18
9
Answer
(ii) Describe in detail the purpose of lines 109 to 117 in the ScanFile() function. Do not
use pseudocode in your answer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
© UCLES 2018 9608/22/O/N/18
11
(b) The function ScanFile() is to be amended so that the first 7 characters of FileData are
not written to the array.
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/22/O/N/18 [Turn over
12
(c) (i) State how structured programming languages support the implementation of sub-tasks.
.......................................................................................................................................[1]
...........................................................................................................................................
.......................................................................................................................................[1]
Write program code to declare ResultArray and set all elements to the value "NO DATA".
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[3]
For example, when the procedure reads MyFile.txt, the output is:
After every 20 lines, the program outputs a message asking whether the user wants to continue.
The program ends when the user enters an 'N' or the end of file is reached.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
© UCLES 2018 9608/22/O/N/18
15
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [11]
© UCLES 2018 9608/22/O/N/18 [Turn over
16
Appendix
Built-in functions (pseudocode)
Each function returns an error if the function call is not properly formed.
Example: If x has the value 87.5 then NUM_TO_STRING(x) will return "87.5"
Note: This function will also work if x is of type integer.
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