Functions and Procedures (OCR A-Level Computer Science): Flashcards

📚Flashcards
Functions and Procedures
Sign up to keep revising.Create a free account to study more flashcards and track your progress.

Practise the cards

14 cards from this deck

Show

Definition of a function

Code block that performs a task & returns a value

Definition of a procedure

Code block that performs a task but doesn't return a value

Key difference: function vs procedure

Functions return a value; procedures don't

When to use a function

When the result needs to be used elsewhere in the program

When to use a procedure

To modify data, interact with user, or output without return

How functions are typically integrated

Used within expressions or other functions

How procedures are typically called

As standalone statements

Benefit: Code reusability

Functions/procedures can be called multiple times, reducing duplication

Benefit: Improved readability

Breaking program into smaller sections makes it easier to read

Benefit: Testing & debugging

Individual functions/procedures can be tested independently

Benefit: Collaborative development

Team members can work on different functions/procedures

Common mistake with procedures

Attempting to use a RETURN statement in a procedure

Common mistake with functions

Forgetting to store or use the returned result

Use for mathematical calculations

Functions (e.g., calculateArea, findMaximum)

Explore OCR A-Level Computer Science Revision Notes by Topics

Explore OCR A-Level Computer Science Model Answers by Topics

Explore OCR A-Level Computer Science Quizzes by Topics

Explore OCR A-Level Computer Science Exam Questions by Topics

Join 100,000+ A-Level students studying Flashcards with us.

Select your subjects, and get access to A+ resources today.