Procedures and Functions
Procedures and Functions
Tick () one box which accurately describes the use of the variable Inches
A answer
B call
C parameter
D response
[1]
© UCLES 2020 2210/02/SP/23
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(a) Write pseudocode statements to declare the variables P and Q, store "The world" in P and
store 'W' in Q
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(c) Give the value of Position after the algorithm has been executed with the data in
question 11(a).
...................................................................................................................................................
............................................................................................................................................. [1]
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
8 Explain why a programmer would use procedures and parameters when writing a program.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [4]
(a) Draw one line to link each description to the most appropriate 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
[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]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
Make sure that any variables used are declared and that both text files are closed after they have
been used.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
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]
10 The variables X, Y and Z are used in a program: X stores a whole number, Y stores a decimal
number and Z stores a flag that can be set to TRUE or FALSE
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) The function Same(A,B) returns TRUE if the value of A is the same as the value of B when B
is rounded to the nearest whole number and FALSE otherwise.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
...................................................................................................................................................
............................................................................................................................................. [1]