Computing
Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

Lesson Video

28

Lesson Tasks

  • Watch the Lesson video
    Make notes on your notes sheet.
  • Read the lesson notes
    Make notes on your notes sheet.
  • Complete the learning activities
    Make any notes on your notes sheet.
  • Check the Learning outcomes
    Update your learning objectives

What do I need to Learn?

I need to learn how to understand the concept of subroutines.
I need to learn how to explain the advantages of using subroutines in programs.
I need to learn how to describe the use of parameters to pass data within programs.

Key Terms

Procedure Subroutines Identifier Parameters local variable global variable scope

Using Procedures - Learning Activities


In computer programming, a procedure is a set of coded instructions that tell a computer how to run a program or calculation.

Many different types of programming languages can be used to build a procedure. Depending on the programming language, a procedure may also be called a subroutine, subprogram or function.

Parameters

We can also pass information to our procedure through parameters.

The terms parameter and argument are sometimes used interchangeably. However, parameter refers to the type and identifier, and arguments are the values passed to the function.

Below you can see our procedure has a single parameter called 'name' which we use to say hello to a person.


Coding activities

1. Simple Procedure
Create a procedure called hello PROCESS - Call the hello procedure four times
OUTPUT - The word hello is output four times

2. Simple Procedure with parameter
Create a procedure called userName USERINPUT - User enters their name
OUTPUT - The users name is output with a message

3. Simple Procedure
Create a procedure called userMenu OUTPUT - The userMenu is output with a message

4. Single Parameter
USERINPUT - The user enters a number
PROCESS A procedure called double is given the number
OUTPUT - The procedure outputs the value of the number doubled

5. Double Parameter
USERINPUT - The user enters two numbers
PROCESS A procedure called multiply is given the two numbers
OUTPUT - The procedure outputs the value of the numbers multiplied together

Extension
Click on the button below and complete as many exercises as you can

Exercises

Learning Outcomes

I can copy code to use a procedure with a parameter.

I can create my own code to to use a procedure with a parameter.

I can create my own procedure that uses multiple parameters.

Update your objectives

control