Paper 2 Exam 6
Paper 2 Exam 6
Paper 2 Exam 6
* 9 0 6 0 9 6 0 7 7 2 *
INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● Calculators must not be used in this paper.
INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.
DC (KN/SG) 202761/2
© UCLES 2021 [Turn over
2
1 Draw a line to connect each Data Type to the most appropriate Description.
2 Identify a suitable validation check that could be used for each piece of normal test data and
describe how it would be used. Each validation check must be different.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[6]
3 The pseudocode algorithm should allow a user to input the number of scores to be entered and
then enter the scores. The scores are totalled, the total is output and the option to enter another
set of scores is offered.
1 Count 0 ←
2 REPEAT
3 FullScore 20 ←
4 INPUT Number
5 FOR StoreLoop 1 TO Number ←
6 INPUT Score
7 FullScore FullScore ←
8 UNTIL StoreLoop = Number
9 OUTPUT "The full score is ", FullScore
10 OUTPUT "Another set of scores (Y or N)?"
11 OUTPUT Another
12 IF Another = "N"
13 THEN
14 Count 1 ←
15 ENDIF
16 UNTIL Count = 1
(a) Identify the four errors in the pseudocode and suggest a correction for each error.
Error 1 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 2 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 3 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 4 .......................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
[4]
(b) Show how you could change the algorithm to store the individual scores in the array
ScoreArray[], then find and print the average score once the scores have all been entered.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
START
INPUT
Op
IS No
Op = 0 ?
Yes
INPUT
Value1
INPUT
Value2
IS Yes
Op = 1 ? Ans Value1 + Value2
END No
IS Yes
Op = 2 ? Ans Value1 - Value2
No
IS Yes
Op = 3 ? Ans Value1 * Value2
No
IS Yes
Op = 4 ? Ans Value1 / Value2
No
OUTPUT
"Input Error"
(a) Complete the trace table for the algorithm using this input data:1,
[5]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [1]
(c) Suggest an addition that could be made to the algorithm to make it more useful.
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [1]
5 A car hire company uses a database table, TREAD, to store details of the cars. The table has
fields to represent each car’s licence number, mileage, and the tread depth of each of its four
tyres.
Field name
[2]
(b) Give two validation checks that could be performed on the licence number field
..........................................................................................................................................
..........................................................................................................................................
[2]
(c) Complete the structured query language (SQL) to display cars where all four tyres have a tread
depth of less than 2. Display all the fields. The output should be sorted by licence number.
SELECT .................................................................................................................................
FROM .....................................................................................................................................
WHERE ....................................................................................................................................
ORDER BY .............................................................................................................................;
[4]
X
B
(a) Two NOT gates are used in the given logic circuit.
Identify three other logic gates that are used in the given logic circuit.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ................................................................................................................................................
[3]
(b) Consider the completed truth table for the given logic circuit.
2 0 0 1 1
3 0 1 0 0
4 0 1 1 0
5 1 0 0 1
6 1 0 1 1
7 1 1 0 0
8 1 1 1 1
There are four errors in the truth table in the output (X) column.
Row .......................
Row .......................
Row .......................
Row .......................
[4]
[4]
Show the value of the variable after each pseudocode statement has been executed.
02 Q ¬ LENGTH(P) ............................................................................................................
03 R ¬ SUBSTRING(P,6,5) ............................................................................................
04 S ¬ LENGTH(R) ..............................................................................................................
05 T ¬ SUBSTRING(R,2,3) ............................................................................................
[5]
Function definition
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Function call
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.......................................................................................................................................................[6]
Explain using examples why you would choose to use each loop structure.
Example 1 .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Example 2 .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
................................................................................................................................................[6]
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
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.
118 A one-dimensional (1D) array Employees[] contains the names of employees in a law
firm. A two-dimensional array Salaries[] contains the monthly salary of each
employe in each month. The position of each employee data in the two arrays is the
same, for example, the employee in position 5 in Employees[] and Salaries[] is
the same.
The variable FirmSize contains the number of employees in the firm. The variable
Months contains the number of months of operation in the firm. All employees have
worked in the firm the same number of months.
The company allocates a monthly budget ranging from 50,000 EGP to 60,000 EGP.
Write a program that meets the following requirements:
• calculates the total salary paid by the law firm in each month
• find and output the number of months where the firm has gone over budget
• find and output the number of months where the firm has gone under budget
• find and output the number of months where the firm has been within budget
• find and display the average monthly wage paid by the firm to all employees
You must use pseudocode or program code and add comments to explain how your
code works.
You do not need to declare any arrays, variables or constants; you may assume that
this has already been done.
All inputs and outputs must contain suitable messages.You do not need to initialise the
data in the arrays Employees[] and Salaries[] or the variables FrimSize and
Months
The arrays and variables have already been set up and the data is stored.
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
187
Nested Loops & 2D Arrays Eng. Omar El Safty
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
......................................................................................................................................................15
188