Tracing Algorithms Questions 15.11.2024
Tracing Algorithms Questions 15.11.2024
1 of 12 Created in ExamBuilder
1 Read the following pseudocode algorithm:
01 start = 3
02 do
03 print(start)
04 start = start - 1
05 until start == -1
06 print("Finished")
[3]
2 Each member of staff that works in a restaurant is given a Staff ID. This is calculated using the
following algorithm.
06 endwhile
07 print(“ID ” + staffID)
(i) Define the term casting and give the line number where casting has been used in the algorithm.
Definition
Line number
[2]
Complete the following trace table for the given algorithm when the surname “Kofi” and the year 2021
are entered.
02 2021
[4]
© OCR 2024. You may photocopy this page. 2 of 9 Created in ExamBuilder
3 OCR Drones flies goods around the country using drones.
A pilot code is automatically generated when a new pilot joins the company.
You may not need to use all rows in the trace table.
Line number a b c pilotCode Output
01 H
02 K
03 9
[4]
x = 15 y = 0
while x > 0
y = y + 1 x
= x – y
endwhile
print(y)
x y output
[4]
5(a) A computer program calculates the correct dose in grams of a type of medicine.
Use the flow diagram to calculate the correct dose of medicine for a male aged 30.
[4]
6 Charley is writing a program for music students. To make sure that there are no logic errors in the
program, Charley uses a test plan.
[2]
7 Heath is researching how long, to the nearest minute, each student in his class spends playing
computer games in one week (Monday to Friday). He is storing the data in a 2D array.
For example, student 1, on Monday (day 0), played 30 minutes of computer games.
He wants to output the number of minutes student 3 played computer games on Wednesday (day 2).
He writes the code:
print (hoursPlayed[3,2])
[1]
[1]
[1]
(iii) Write an algorithm to output the total number of minutes student 0 played computer games from
Monday (day 0) to Friday (day 4).
[3]
8 OCR Tech is an online shop that sells electronics such as TVs and game consoles.
A program is written that allows the user to input the current stock level and output whether the item is
in demand or not.
Refine the program to correct the errors and write the refined version of the program.
[5]
value = value - 1
print(value * 2)
[1]
number = scores[2]
print(number)
[1]
x = day.length
print(x)
[1]
10 State what is meant by the term syntax error. Give one example of a syntax error in a program.
Definition
Example
[2]