Professional Documents
Culture Documents
Cambridge International General Certificate of Secondary Education
Cambridge International General Certificate of Secondary Education
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.
This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.
DC (NF) 148543/2
© UCLES 2018 [Turn over
2
1 (a) Write an algorithm to input 1000 numbers. Count how many numbers are positive and how
many numbers are zero. Then output the results. Use either pseudocode or a flowchart.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [6]
3
(b) Give one change you could make to your algorithm to ensure initial testing is more
manageable.
...................................................................................................................................................
.............................................................................................................................................. [1]
[Turn over
4
2 The global trade item number (GTIN-8) barcode has seven digits and a check digit.
This pseudocode algorithm inputs seven digits and calculates the eighth digit, then outputs the
GTIN-8.
DIV(X,Y), finds the number of divides in division for example DIV(23,10) is 2.
MOD(X,Y), finds the remainder in division for example MOD(23,10) is 3.
FOR Count 1 TO 7
INPUT Number
Digit[Count] Number
NEXT
Sum (Digit[1]+Digit[3]+Digit[5]+Digit[7])*3+Digit[2]+Digit[4]+Digit[6]
IF MOD(Sum,10) <> 0
THEN Digit[8] DIV(Sum,10)*10 + 10 - Sum
ELSE Digit[8] 0
ENDIF
OUTPUT "GTIN-8"
FOR Count 1 TO 8
OUTPUT Digit[Count]
NEXT
Digit[1] Digit[2] Digit[3] Digit[4] Digit[5] Digit[6] Digit[7] Digit[8] Sum OUTPUT
Digit[1] Digit[2] Digit[3]) Digit[4] Digit[5] Digit[6] Digit[7] Digit[8] Sum OUTPUT
[5]
5
(b) Explain how you would change the algorithm to input eight digits (seven digits and the check
digit) and output if the check digit entered is correct or not.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................. [3]
[Turn over
6
3 A programmer has written a routine to check that prices are below $10.00. These values are used
as test data.
10.00 ................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
9.99 ..................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
ten ....................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[3]
4 Explain the difference between the programming concepts of counting and totalling.
Include an example of a programming statement for each concept in your explanation.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..................................................................................................................................................... [4]
7
Fields ........................................................................................................................................
Records ....................................................................................................................................
[2]
(b) Give two validation checks that could be performed on the ShowNumber field.
...................................................................................................................................................
...................................................................................................................................................
[2]
(c) Write a SQL statement to identify jazz performances that are not sold
out. Only display the date and the title.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..................................................................................................................................................... [4]
8
State three possible benefits of using library routines in the development of the program.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
(b) The following pseudocode is part of a program that stores names and test marks for use in
other parts of the program.
(i) The pseudocode needs to be changed to allow for data to be stored for up to 30 students.
Explain why it would be good practice to use arrays to store the data.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
9
State the purpose of the variable Count and give its data type.
Purpose .............................................................................................................................
...........................................................................................................................................
[Turn over
10
7 A system is being developed to help manage a car hire business. A customer may hire a car for a
number of days.
(a) Explain the process of abstraction and state four items of data that should be stored each
time a car is hired.
Explanation ...............................................................................................................................
...................................................................................................................................................
Item 1 ........................................................................................................................................
Item 2 ........................................................................................................................................
Item 3 ........................................................................................................................................
Item 4 ........................................................................................................................................
[3]
(b) Identify two operations that would be required to process the car hire data.
Operation 1 ...............................................................................................................................
...................................................................................................................................................
Operation 2 ...............................................................................................................................
...................................................................................................................................................
[2]
11
8 A 1D array Data of type integer contains 200 elements. Each element has a unique value.
An algorithm is required to search for the largest value and output it.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
[Turn over
12
9 A program uses two 1D arrays of type integer. Array1 contains 600 elements and Array2
contains 200 elements.
Array1 contains sample values read from a sensor. The sensor always takes three consecutive
samples and all of these values are stored in Array1.
A procedure Summarise() will calculate the average of three consecutive values from Array1
and write the result to Array2. This will be repeated for all values in Array1.
The diagram below illustrates the process for the first six entries in Array1.
}
Array1 Array2 Comment
}
15
40
41
42
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
13
NewString "" ←
INPUT InputString
j ← LENGTH(InputString)
FOR i ←
1 TO j
NextChar ←
SUBSTRING(InputString, i, 1)
IF NextChar <> " "
THEN
// the & character joins together two strings
NewString ←
NewString & NextChar
ENDIF
NEXT i
OUTPUT NewString
[2]
14
The function:
• has identifier RemoveSpaces
• has a single parameter
• will include the declaration for any local variables used by the function
// main program
INPUT MyString
ChangedString ← RemoveSpaces(.........................................................................................)
OUTPUT ChangedString
// function definition
.................................................................................................................................................
.................................................................................................................................................
.................................................................................................................................................
.................................................................................................................................................
j ← LENGTH(InputString)
FOR i ← 1 TO j
NextChar ←SUBSTRING(InputString, i, 1)
IF NextChar <> " "
THEN
// the & character joins together two strings
NewString ← NewString & NextChar
ENDIF
NEXT i
.................................................................................................................................................
ENDFUNCTION
[4]
15
11 A teacher wants to write a program to help young children learn their multiplication tables.
The teacher wants the program to:
show a visual representation of a multiplication
ask the child to key in an answer.
For example, the multiplication of 3 × 4 is represented as shown.
[2]
16
(b) The procedure CheckAnswerCorrect gives the child three chances to type in the correct answer.
OUTPUT "Correct. Well done! " if the child typed the correct answer,
OUTPUT "You need to practice more. The correct answer is ", Result
if all three attempts are incorrect.
Write an algorithm using pseudocode for the procedure CheckAnswerCorrect .
You must add comments to explain how your code works.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[13]
17
B X
[6]
(b) Complete the truth table for the given logic statement.
Working space
A B C X
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
[4]