Programming – O Level Computer Science (2210)
174 questions · page 4 of 12 · Clear filters
Question text
11
A database table called Booking28 stores details of hotel rooms and bookings for the week
beginning Monday 7 July 2025.
RoomNo
Type
Guests
Rate$
Mon
Tue
Wed
Thu
Fri
Sat
Sun
101D
Double
2
99.99
T
T
T
T
F
T
T
102D
Double
2
99.99
T
T
T
F
T
T
T
103F
Family
4
150.00
T
T
T
T
T
T
T
104S
Single
1
72.50
F
T
T
F
T
T
T
105S
Single
1
72.50
F
T
T
F
T
T
T
106T
Twin
2
120.00
T
T
T
T
F
T
T
201F
Family
4
160.00
F
F
T
T
T
T
T
202D
Double
2
120.00
T
F
T
T
T
T
T
203T
Twin
2
120.00
T
F
T
T
T
T
T
204T
Twin
2
125.00
T
F
T
F
T
T
T
205S
Single
1
79.99
T
F
T
T
F
T
T
301D
Double
2
200.00
F
T
T
F
F
T
T
302T
Twin
2
200.00
T
T
T
T
F
T
T
303P
Suite
4
500.00
T
T
T
T
F
T
T
304P
Suite
6
700.00
F
F
F
F
T
T
T
(a) State the number of fields and records in this database table.
Fields …
Records …
[2]
(b) State the reason why the Type field would not be suitable as a primary key.
…
… [1]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞù¸þ×
,
,
(c) The database uses only the data types:
•
alphanumeric
•
character
•
Boolean
•
integer
•
real
•
date/time.
Complete the table to show the fields that could have the given data types.
Only one field name is required in each box and each field name must be different.
Field
Data type
alphanumeric
Boolean
real
integer
[2]
(d) Give the output that would be produced by the structured query language (SQL) statement:
SELECT RoomNo, Type, Guests, Rate$
FROM Booking28
WHERE Mon <> T;
…
…
…
…
…
… [3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¸þ×
Question text
12 A one-dimensional (1D) array Rooms[] contains the names of up to 20 rooms in a house.
A two-dimensional (2D) array Dimensions[] is used to store the length, width and area of each
room.
The position of any room’s data is the same in both arrays. For example, the data in index 5 of
Dimensions[] belongs to the room in index 5 of Rooms[]
The variable Number stores the number of rooms for which data is to be input. There must be at
least 3 rooms but no more than 20.
Write a program that meets the following requirements:
•
allows the number of rooms for which data is required to be input, stored and validated
•
allows the name of the room and the length and width of the room, in metres, to be entered
and stored
•
allows the area of each room to be calculated as length multiplied by width and stored as
square metres rounded to two decimal places
•
calculates the average size of all the rooms by area, in square metres, rounded to two decimal
places
•
finds the largest room and smallest room by area
•
outputs the names of all rooms with their dimensions and area
•
outputs the names of the largest room and smallest room by area
•
outputs the total area of the house and the average size of all the rooms by area.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; you may assume that this has already been
done.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊàù¸Ā×
,
,
…
…
…
…
Question text
6
An incomplete algorithm has been written in pseudocode to count the number of values stored in
an array and to find their average.
Values have been stored in the array starting at A[1]
All the values to be counted are non-zero.
A value of zero in the array indicates there are no more values stored.
01 DECLARE A : ARRAY[1:50] OF INTEGER
02 DECLARE C : INTEGER
03 DECLARE W : INTEGER
04 DECLARE X : INTEGER
0
05 W
…
06 C
07 WHILE A[C] <> 0
…
08
W
C + 1
09
C
10 ENDWHILE
…
11 X
(a) Complete the given pseudocode algorithm.
[3]
(b) Write pseudocode to display, with suitable messages:
•
the number of values stored in the array
•
the average of those values stored.
…
…
…
…
…
… [3]
ĬÍĊ®Ġ´íÈõÏĪÅĊßú·Ā×
,
,
(c) Meaningful identifiers have not been used in this algorithm.
Suggest suitable meaningful identifiers for:
The array
A …
The variables
C …
X …
W …
[3]
Question text
9
A flowchart checks that values stored in three variables are identical.
If they are different, the highest value is stored in all three variables.
START
No
Is A = B AND
STOP
B = C ?
Yes
Yes
Is A >= B OR
B
A
A >= C ?
C
A
No
Yes
Is B >= A AND
A
B
B >= C ?
C
B
No
A
C
B
C
Identify four errors in the flowchart and suggest a correction for each error. You may label each
error on the diagram with the corresponding error number.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞú¶þ×
Question text
10 An algorithm has been written in pseudocode to check that a password meets a set of rules.
01
OUTPUT "Please enter password "
02
INPUT Password
TRUE
03
Accept
04
IF LENGTH(Password) < 8 OR LENGTH(Password) > 20
05
THEN
FALSE
06
Accept
07
ENDIF
08
IF LCASE(Password) = Password OR UCASE(Password) = Password
09
THEN
FALSE
10
Accept
11
ENDIF
1
12
Index
FALSE
13
Found
14
WHILE NOT Found AND Accept AND Index < LENGTH(Password)
15
IF SUBSTRING(Password, Index, 1) = '!'
16
THEN
TRUE
17
Found
18
ENDIF
Index + 1
19
Index
20
ENDWHILE
21
IF NOT Found
22
THEN
FALSE
23
Accept
24
ENDIF
25
IF Accept
26
THEN
27
OUTPUT "Accepted"
28
ELSE
29
OUTPUT "Rejected"
30
ENDIF
(a) Complete the three trace tables using the data shown for each one.
Data: MYWORD
Password
Accept
Index
Found
OUTPUT
ĬÑĊ®Ġ´íÈõÏĪÅĊàü¶Ā×
,
,
Data: M!word
Password
Accept
Index
Found
OUTPUT
Data: My!Hidden
Password
Accept
Index
Found
OUTPUT
[6]
(b)
State the rules that the password must meet.
…
…
…
…
…
… [3]
ĬÓĊ®Ġ´íÈõÏĪÅĊàú¶Ā×
Question text
12 Members of a litter picking group complete a litter pick every month. Members’ names are stored
in one-dimensional (1D) array PickerName[]
Each member stores the weight of the litter they have picked in another one-dimensional (1D)
array PickedWeight[]
The weights are in kilograms with one decimal place, for example 8.4
The position of each member’s data in the two arrays is the same. For example, the member
stored at index 10 in PickerName[] and at index 10 in PickedWeight[] is the same.
Every month, there is a small prize awarded to the members of the group who have the two
heaviest weights. Certificates are awarded to all members with a pick weight of over three
kilograms.
Write a program that meets the following requirements:
•
allows the weight of members’ picks to be input and validated
•
sorts the arrays PickedWeight[] and PickerName[] in descending order of weight
•
outputs the member names and the pick weights of the members with the two heaviest picks
and identifies them as “Best in Group” and “Second best in Group”
•
stores the names of all the members who will receive a certificate in the array
PickerCertificate[]
•
outputs a message stating the number of certificates to be printed.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; 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 array PickerName[]
…
…
…
…
…
…
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊßü¸Ā×
,
,
…
…
…
…
Question text
2
Four descriptions of programming concepts and five programming concepts are shown.
(a) Draw one line to link each description to the most appropriate programming concept.
Not all programming concepts will be used.
Description
Programming concept
function
a subroutine that may not return a value
procedure
a value that is declared and used within a
specific procedure
parameter
a value that a procedure expects you to
supply when it is called
global variable
a subroutine that will always return a value
local variable
[4]
(b) Write the pseudocode to use a procedure named Average that passes the values 25 and 50
to the procedure.
…
… [2]
(c) Outline the role of procedures and functions in creating a program that is easier to maintain.
…
…
…
…
…
… [3]
Question text
3
State what is meant by the data types integer and real.
Give an example of each.
Integer …
…
Example …
Real …
…
Example …
[4]
Question text
4
This pseudocode algorithm is intended to allow, at random, between 1 and 20 values to be entered
and totalled. The total and average of the entered values are output at the end of the algorithm.
01
DECLARE Loop : STRING
02
DECLARE Limit : INTEGER
03
DECLARE Value : REAL
04
DECLARE Total : REAL
0
05
Total
ROUND(RANDOM() * 19,0) + 1
06
Limit
1 TO Limit
07
IF Loop
08
OUTPUT "Enter a number"
09
INPUT Loop
Total * Value
10
Total
11
NEXT Loop
12
OUTPUT "The total of the numbers entered is ", Total
13
OUTPUT "The average of the numbers entered is ", Total / Limit
(a) Identify the line numbers of four errors in the pseudocode and suggest corrections.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
(b) Write the pseudocode statement that would output the average calculated in line 13 of the
algorithm rounded to one decimal place.
…
…
…
… [2]
(c) Explain how you should alter the original corrected algorithm to make sure that all the
numbers entered are between 1 and 500 inclusive. If any numbers fall outside these limits, a
replacement value is requested and entered.
You do not need to re-write the algorithm.
…
…
…
…
…
Question text
5
Write the pseudocode statements to perform this task:
•
accept the input of a whole number from 1 to 4 inclusive
•
use a CASE statement to:
○ output the number (1 to 4 inclusive) that was entered
○ output the word “ERROR” if a 1 to 4 inclusive number was not entered.
…
…
…
…
…
…
…
…
…
… [5]
Question text
7
(a) Outline why it is useful to store data in a file.
…
…
…
… [2]
(b) The function LENGTH(X) calculates the length of a string X
Write the pseudocode statements to:
•
read the contents of the text file Quotation.txt into an appropriate string variable that
has been declared
•
output the string in upper case and the length of the string.
…
…
…
…
…
…
…
… [4]
Question text
10 The one-dimensional (1D) array Clubs[] is used to store the names of 12 cricket clubs in a local
sports league.
The two-dimensional (2D) array Statistics[] is used to store, for each cricket club, the number
of:
•
matches won
•
matches drawn
•
matches lost.
The 1D array Points[] is used to store the total number of points each cricket club has been
awarded.
The position of any cricket club’s data is the same in all three arrays. For example, the data in
index 2 of Statistics[] and index 2 of Points[] belongs to the cricket club in index 2 of
Clubs[]
The variable Matches stores the number of matches played by each team. Each team plays the
same number of matches.
Points are awarded for:
•
a win – 12 points
•
a draw – 5 points
•
a loss – 0 points.
Write a program that meets the following requirements:
•
allows the number of matches played to be input and stored, with a maximum of 22 matches
•
validates the number of matches played
•
allows the names of the cricket clubs to be input and stored
•
allows the number of matches won, drawn and lost to be input and stored for each team
•
validates the number of matches won, drawn or lost against the number of matches played
•
asks the user to re-enter the number of matches won, drawn or lost if the total does not match
the number of matches played
•
calculates and stores the total number of points for each club
•
finds the cricket club or clubs with the highest number of points
•
outputs the name or names of the winning club or clubs, the number of wins and the total
number of points awarded.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables; you may assume that this has already been
done.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
4
A program needs to make sure the characters input for a product code meet these rules:
•
The product code is six characters in length.
•
The first two characters must be “PD”.
•
The last four characters must be a number in the range 1000 to 9999 inclusive.
(a) Identify three validation checks and state how each check would make sure the product code
met one of these rules.
Check 1 …
…
…
Check 2 …
…
…
Check 3 …
…
…
[6]
(b) The program design will include a pseudocode algorithm. Assume that the product code is
stored in the variable Product
(i)
Write the pseudocode to make sure that the product code is six characters in length.
…
…
…
…
… [2]
(ii)
Write the pseudocode to make sure that the first two characters of the product code are
“PD”.
…
…
…
…
… [2]
Question text
5
A high-level programming language makes use of arithmetic, Boolean and logical operators.
State how each type of operator is used.
Give an example statement, in pseudocode, for each one.
Arithmetic …
…
Example …
…
Boolean …
…
Example …
…
Logical …
…
Example …
…
[6]
Question text
7
An algorithm has been written in pseudocode to find and display the maximum and minimum
values in an array of 1000 positive numbers. The array List[] starts at index 1
List[1]
01
Max
List[1]
02
Min
2 TO 1000
03
FOR Counter
04
IF List[Counter] < Max
05
THEN
List[Counter]
06
Max
07
ENDIF
08
IF List[Count] ˂ Min
09
THEN
List[Counter]
10
Min
11
ENDWHILE
12
NEXT Counter
13
OUTPUT "Maximum value is ", Max
14
OUTPUT "Minimum value is ", Min
(a) Give a line number for each of these types of statement:
Assignment statement …
Selection statement …
Iteration statement …
[3]
(b) Identify the line numbers of the three errors in the pseudocode and suggest a correction for
each error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
[3]