GCSE Computer Science – Chapter 7-7 - Question Template
Questions
1) Examine the OCR ERL below.
x = 5
y = 6
z = sub_area(x, y)
a) Identify one variable.
a)X[1]
b) Identify one subroutine.
Sub_area [1]
2) Examine the OCR ERL below.
function sub_c(cash)
x = 0
for i = 1 to [Link] – 1
x = x + cash[i]
next i
return x
endfunction
a) Identify one parameter.
Cash [1]
b) Suggest a datatype for the parameter.
Integer [1]
c) cash is an array of numbers. State the purpose of this subroutine?
To print the numbers held in the array cash. [1]
d) State one word other than SUBROUTINE and ENDSUBROUTINE that shows
that sub_c is a subroutine.
Subprogram [1]
© 2021
GCSE Computer Science – Chapter 7-7 - Question Template
3) In programming, variables have a scope.
a) Describe the difference between a local variable and a global variable. [2]
b) Explain two advantages of using local variables. [4]
4) List all the possible values of <answer> in the pseudo-code below: [3]
a) answer = random(11, 15)
11,12,13,14,15
b) answer = random(1, 10) * 10
10,20,30,40,50,60,70,80,90,100
5) Subroutines can be used within programming.
a) Other than the use of local variables, explain two advantages of using
subroutines.
Subroutines are lines of code which can be called into the program to perform a
function at any given time. This saves the coder writing out the code every
time its needed thereby saving time. Subroutines also improve the testing
and debugging process of coding. [4]
b) State the difference between a function and a procedure.
Procedures perform a task but don't return a value. Functions manipulate data and
return a value to the program. [1]
6) Examine the OCR ERL below.
function sub_p(x)
z = [Link]([Link]–1, 1)
return z
endfunction
a) State the purpose of this function?
The purpose of this function is to take some of the string from the value x and
return this value to the program in the form of z. [1]
The main program includes this code:
y = sub_p(“Hello”)
© 2021
GCSE Computer Science – Chapter 7-7 - Question Template
b) What is the value of y?
Y=oHe [1]
c) Suggest a more meaningful identifier name for sub_p.
Function [1]
© 2021
GCSE Computer Science – Chapter 7-7 - Question Template
7) A developer has decomposed a problem for the basic operations of an electronic
till in a shop.
Till
Lookup
Calculate
Scan barcodes products and Calculate total
change
prices
The developer wants to implement each sub-problem as a subroutine.
The subroutine for calculating the total will include a parameter to receive an
array of the prices that were found when looking up the products and prices.
The subroutine must return the value of the total of all the prices.
Create a function that solves this sub-problem. [7]
© 2021