Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Additional Programming Techniques

Sub programs (functions and procedures) to produce structured code

How to use sub programs (functions and procedures) to produce structured code

2.2.3 Additional Programming Techniques

Practise exam questions

Additional Programming Techniques — Note 8 of 13

The difference and use of functions and procedures and where to use them effectively

What you need to know

Sub-programs (also called sub-routines) are reusable blocks of code that perform a specific task. There are two types: functions return a value, while procedures perform a task without returning a value. Using sub-programs makes code modular, reusable, and easier to test and maintain.

What to know

  • A function performs a task and RETURNS a value using the return keyword.
  • A procedure performs a task but does NOT return a value (it may print output instead).
  • Parameters are values passed into a sub-program when it is called. They MUST be used within the function.
  • A calculation passed as an argument is worked out FIRST, so printArea(width * height) passes ONE value. Arguments are separated by commas: printArea(width, height) passes two.
  • Sub-programs must be CALLED in the main program to execute. Calling: totalPay = calculatePay(experience, miles).
  • Using sub-programs makes code modular, reusable, and easier to maintain. 'More efficient' on its own is not credited: say HOW, for example the code is written once and called many times.
  • Code does not need to be repeated; the sub-program can be called multiple times.
  • A procedure is called on its own line: greet("player1"). A function call is used inside an assignment or expression, because it gives back a value: total = add(5, 3).

Code examples

Function vs procedure (OCR Exam Reference Language)
text
// FUNCTION: returns a value
function hireCost(hours, boat)
    if boat == "kayak" then
        cost = 12 * hours
    else
        cost = 20 * hours
    endif
    return cost            // RETURN, not print
endfunction

// PROCEDURE: does not return a value
procedure greet(name)
    print("Hello " + name)
endprocedure

// Calling them
result = hireCost(3, "canoe")   // the returned value is stored
print(result)                    // 60
greet("player1")                 // a procedure call on its own line
Function vs Procedure
python
# FUNCTION - returns a value
def hireCost(hours, boat):
    if boat == "kayak":
        cost = 12 * hours
    else:
        cost = 20 * hours
    return cost   # RETURN, not print

# CALLING the function:
result = hireCost(3, "canoe")
print(result)  # Output: 60

# PROCEDURE - does not return a value
def greet(name):
    print("Hello, " + name + "!")

greet("player1")  # Output: Hello, player1!
Calling a function vs calling a procedure
python
# Function: returns a value
def add(x, y):
    return x + y

total = add(5, 3)    # the returned value is stored
print(total)         # 8

# Procedure: does a job, returns nothing
def greet(name):
    print("Hello", name)

greet("player1")     # outputs: Hello player1

Exam technique

  • Mistake:DO NOT overwrite parameters by asking for input inside the function. If hours and boat are given as parameters, USE them — don't do hours = input() inside the function.
  • Mistake:Writing the function out again, or working the answer out another way, when the question asks you to CALL it. A call is the function's name with its arguments, and the result is stored: cost = hireCost(2, "kayak").
  • Tip:A function must RETURN its result — not just print it. Use return total, not print(total), inside the function.
  • Tip:When CALLING a function, string parameters need quotation marks: freeseats("Red"), not freeseats(Red). Store the result: redseats = freeseats("Red").
  • Tip:You can define the function THEN call it separately: result = hireCost(3, "canoe") then print(result).
  • Example:Refining to use a function means replacing inline code with a function call: totalPay = calculatePay(experience, miles) then print(totalPay).

Ready to test yourself?

Practise 2.2.3 questions
← Previous notetwo-dimensional arrays(2D)2.2.3 Additional Programming TechniquesNext note →local variables2.2.3 Additional Programming Techniques

Back to Additional Programming Techniques

Revise another OCR GCSE topic: Programming Fundamentals

Additional Programming Techniques

Note 8 of 13

  1. 1Concatenation
  2. 2slicing
  3. 3ASCII Conversion
  4. 4Open, Read, Write, Close
  5. 5Records to store data
  6. 6SQL to search for data
  7. 7one-dimensional (1D)
  8. 8two-dimensional arrays(2D)
  9. 9Sub programs (functions and procedures) to produce structured code
  10. 10local variables
  11. 11global variables
  12. 12arrays
  13. 13Random number generation
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).