Programming – IGCSE Computer Science (0478)
270 questions · page 7 of 18 · Clear filters
Question text
5
The flowchart represents an algorithm.
START
L
0
S
10000
T
0
A
0
INPUT
Limit
Count
1
INPUT
Value
IS
IS
No
No
Value < S
Value > L
?
?
Yes
Yes
L
Value
S
Value
T
T + Value
IS
No
Count >
Count
Count + 1
Limit ?
Yes
T / Limit
A
OUTPUT "L = ", L, " S = ",
S, " T = ", T, " A = ", A
STOP
(a) Complete the trace table for the input data:
10, 30, 18, 8, 25, 12, 17, 2, 50, 15, 5
L
S
T
A
Limit
Count
Value
OUTPUT
[6]
(b) Outline the purpose of the algorithm.
…
…
…
… [2]
(c) Explain why the identifiers L, S, T and A may not be appropriate to use as identifiers and how
they could be improved.
…
…
…
…
…
… [3]
(d) State a more appropriate identifier for each of the variables L, S, T and A
Original identifier
Improved identifier
L
S
T
A
[2]
Question text
(a) The string operation SUBSTRING(FullText, X, Y) returns a string from FullText
7
beginning at position X that is Y characters long. The first character in FullText is in
position 1.
Write the pseudocode statements to:
•
store the string “IGCSE Computer Science at Cambridge” in FullText
•
extract and display the words “Computer Science” from the string and store it in a suitable
variable
•
output the original string in upper case.
…
…
…
…
…
… [4]
(b) Write the pseudocode statements to:
•
store the content of the variable you created in part (a) to a text file named
"Subjects.txt"
•
close the text file at the end of the algorithm.
…
…
…
…
…
… [3]
Question text
A one-dimensional (1D) array Teams[] contains the names of 10 football teams in a local league.
9
A two-dimensional (2D) array Results[] stores, for each team, the total number of:
•
games won
•
games drawn
•
games lost
•
points.
The position of any team’s data is the same in both arrays. For example the data in index 3 of
Results[] belongs to the team in index 3 of Teams[]
The array data will be used to find the current leader of the league.
The variable Played stores the number of games played by each team. Each team plays the
same number of games.
Write a program that meets the following requirements:
•
allows the number of games played to be input and stored, with a maximum of 18 games
•
allows the names of the teams to be input and stored
•
allows the number of games won, drawn and lost to be input and stored for each team
•
validates the number of games played and the number of games won, drawn or lost against
the number of games played
•
calculates and stores the number of points for each team using three points for a win and one
point for a draw; there are no points for a loss
•
sorts the array Results[] into descending order of number of points, ensuring the
corresponding parallel array Teams[] is kept in the same order
•
determines how many teams have the highest number of points
•
outputs the name(s) of the winning team(s) along with the number of points achieved.
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
2
(a) Four test data types and five descriptions are shown.
Draw one line to link each test data type to its most appropriate description.
Test data type
Description
abnormal
a value that is accepted
a value that is the highest or lowest value to be accepted and
the corresponding lowest or highest value to be rejected
boundary
a value that is the highest or lowest value to be rejected
extreme
a value that is rejected
a value that is the highest or lowest value to
be accepted
normal
[4]
(b) An algorithm has been written to test if an integer that is input is in the range 5 to 10 inclusive.
Identify an example of suitable test data for each test data type.
Abnormal …
…
Boundary …
…
Extreme …
…
Normal …
…
[4]
Question text
4
Identify three data types used in programming.
1 …
2 …
3 …
[3]
Question text
6
Describe two types of iteration that a programmer can use whilst writing a program.
…
…
…
…
…
…
…
… [4]
Question text
10 A programmer has written a program that will be maintained by another programmer.
Explain how the program can be written to make sure it can be easily maintained by the other
programmer.
…
…
…
…
…
…
…
…
…
…
…
… [6]
Question text
11
Students in a class are recording the amount of time in minutes spent in front of a screen for each
day of the week.
The one-dimensional (1D) array StudentName[] contains the names of the students in the class.
The two-dimensional (2D) array ScreenTime[] is used to input the number of minutes on each
day spent in front of a screen.
The position of each student’s data in the two arrays is the same. For example, the student stored
at index 10 in StudentName[] and ScreenTime[] is the same.
The variable ClassSize contains the number of students in the class.
Write a program that meets these requirements:
•
allows all the students to enter their daily minutes of screen times for the past week
•
calculates the total number of minutes of screen time for each student in the week
•
counts, for each student, the number of days with more than 300 minutes of screen time
•
calculates the average weekly minutes of screen time for the whole class
•
finds the student with the lowest weekly minutes of screen time
•
outputs for each student:
–
name
–
total week’s screen time in hours and minutes
–
number of days with more than 300 minutes of screen time
•
outputs the average weekly minutes of screen time for the whole class
•
outputs the name of the student with the lowest weekly screen time.
You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.
Assume that the array StudentName[] and the variable ClassSize already contain the
required data.
You do not need to declare any arrays or variables; you may assume that this has already been
done.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
1
Tick (3) one box to show which operator means less than or equal to.
A
OR
B
<
C
<=
D
>=
[1]
Question text
2
Tick (3) one box to show how a value can be passed to a procedure.
A
function
B
parameter
C
return
D
subroutine
[1]
Question text
3
Four descriptions of data and five data types are shown.
Draw one line to link each description to the most appropriate data type.
Not all data types will be used.
Description
Data type
BOOLEAN
a whole number
CHAR
a single letter
INTEGER
a word or phrase
REAL
a number with two decimal places
STRING
[4]
Question text
4
Circle the three words representing places where data may be stored.
array
constant
dimension
input
output
procedure
variable
[3]
Question text
6
An algorithm has been written in pseudocode.
01 DECLARE A[1:10] : STRING
02 DECLARE T : STRING
03 DECLARE C, L : INTEGER
10
04 L
1 TO L
05 FOR C
06
OUTPUT "Please enter name "
07
INPUT A[C]
08 NEXT C
1 TO L
09 FOR C
1 TO 9
10
FOR L
11
IF A[L] > A[L + 1]
12
THEN
A[L]
13
T
A[L + 1]
14
A[L]
T
15
A[L + 1]
16
ENDIF
17
NEXT L
18 NEXT C
1 TO L
19 FOR C
20
OUTPUT "Name ", C, " is ", A[C]
21 NEXT C
(a) State the purpose of this pseudocode algorithm.
…
… [1]
(b) State four processes in this algorithm.
1 …
…
2 …
…
3 …
…
4 …
…
[4]
(c) Meaningful identifiers have not been used in this algorithm.
Suggest suitable meaningful identifiers for:
The array:
A …
The variables:
T …
C …
L …
[3]
(d) State two other ways the algorithm can be made easier to understand and maintain.
1 …
…
2 …
…
[2]
Question text
10 Drama students put on a performance of a play for one evening. Seats in a small theatre can be
booked for this performance.
The theatre has 10 rows of 20 seats. The status of the seat bookings for the evening is held in the
two-dimensional (2D) Boolean array Evening[]
Each element contains FALSE if the seat is available and TRUE if the seat is booked.
Up to and including four seats can be booked at one time. Seats are allocated in order from those
available. A row or seat number cannot be requested.
The array Evening[] has already been set up and some data stored.
Write a program that meets the following requirements:
•
counts and outputs the number of seats already booked for the evening
•
allows the user to input the number of seats required
•
validates the input
•
checks if enough seats are available:
–
if they are available
○ changes the status of the seats
○ outputs the row number and seat number for each seat booked
if they are not available:
–
○ outputs a message giving the number of seats left or ‘House full’ if the theatre is fully
booked.
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.
You do not need to initialise the data in the array Evening[]
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
1
Tick (✓) one box to complete the sentence.
Verification is used to make sure that a value entered
A
has not changed during input.
B
is an integer.
C
is correct.
D
is not a string.
[1]