Functions and Procedures A-Level Resources

A Level Computer Science: Functions and Procedures

Do you want to save hours of lesson preparation time? Get your evenings and weekends back and focus your time where it's needed! Be fully prepared with presentations, notes, activities, and more.

All Computer Science topics are covered, and each module comes complete with:

Classroom Presentations
Revision Notes
Activities & Quizzes
Mind Maps, Flashcards & Glossaries

Frequently Asked Questions

What is the main difference between a function and a procedure in programming?

The main difference lies in their return values. Functions return a value to the calling code, providing an output, whereas procedures, also known as void functions, perform a task but do not return a value.

When would you choose to use a function over a procedure in your program?

You would choose to use a function when you need the subroutine to perform a specific task and return a result or output that is relevant to the calling code. Functions are suitable when the calling code requires the computed value for further processing.

Can a function have side effects?

Ideally, functions should not have side effects, as they are designed to produce a specific result based on their input parameters. However, in practice, some functions may have side effects, such as modifying global variables, which is generally discouraged for maintainability and predictability.

How are parameters used in functions and procedures?

Parameters are input values passed to both functions and procedures. Functions use parameters to perform calculations and return a result, while procedures use parameters to receive inputs for their tasks. Parameters help make subroutines more flexible and reusable.

In what scenarios would you use a procedure instead of a function?

You would use a procedure when the task at hand involves performing actions or operations without needing to return a specific value. Procedures are suitable for tasks like printing messages, updating variables, or executing a series of steps without requiring an output for further computation in the calling code.