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

Lesson 4 - Subroutines

Flowcharts and sequencing

Software can be used to create sequences in a flowchart, to view onscreen simulations.

Examples include:
  • Flowol
  • Logicator
  • Crocodile Clips

Basic flowchart symbols

Name Symbol Usage
Terminator

Starts or stops a process.

Input or output

An input is data received by a computer. An output is a signal or data sent from a computer.

Process

An instruction or a command.

Decision

A decision, either yes or no. For example, a decision based on temperature that turns a central heating system on or off.

Line tool

Connects the symbols. The arrow indicates direction.



Flowcharts and sequencing

Software can be used to create sequences in a flowchart, to view onscreen simulations.

Examples include:
  • Flowol
  • Logicator
  • Crocodile Clips

Basic flowchart symbols

Name Symbol Usage
Terminator

Starts or stops a process.

Input or output

An input is data received by a computer. An output is a signal or data sent from a computer.

Process

An instruction or a command.

Decision

A decision, either yes or no. For example, a decision based on temperature that turns a central heating system on or off.

Line tool

Connects the symbols. The arrow indicates direction.



control

Subroutines

In computer programming, a subroutine is a sequence of program instructions that perform a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed. Subroutines are used to :

  • Simplify your code to make it easier to read (or for someone else to read)
  • Avoid having to write the same block of code a number of times
  • Break a bigger problem into smaller steps

subroutine symbol

Task 1 - Lighthouse Using a subroutine to make a light flash

  • Learning Objective - I can develop a control solution for a system that includes a subroutine.

A 'Flash' subroutine

lighthouse mimic

Below is a flowchart for our lighthouse which shows us how we can use a subroutine to make the lighthouse lamp flash by reusing the same flowchart.

lighthouse flow chart

Using the flowchart above create a subroutine called 'flashes' which makes the lighthouse lamp flash, see what the addition of the number below to our subroutine does to our mimic.

subroutine symbol

Update your objectives

control
  • I can develop a control solution for a system that includes a subroutine.

Task 2 - Pelican Crossing

  • Learning Objective - I can break down complex problems into smaller parts to find a solution.

Update your objectives

control
  • I can break down complex problems into smaller parts to find a solution.

Task 3 - Create a Subroutine

pelican crossing mimic
  • Create a subroutine to control only the flashing lights
  • Use the Sub option with a Start / Stop symbol
  • Refer to the Zebra Crossing mimic solution
  • Call the subroutine from the main program
pelican crossing mimic

Update your objectives

control

You should now be able to assess yourself against your objectives:

  • Learning Objectives

  • I can represent algorithms symbolically.
  • I can break down complex problems into smaller parts to find a solution.
  • I can develop a control solution for a system that includes a subroutine.


  • Learning Objectives

  • I can represent algorithms symbolically.
  • I can break down complex problems into smaller parts to find a solution.
  • I can develop a control solution for a system that includes a subroutine.

Flowcharts and sequencing

Software can be used to create sequences in a flowchart, to view onscreen simulations.

Examples include:
  • Flowol
  • Logicator
  • Crocodile Clips

Basic flowchart symbols

Name Symbol Usage
Terminator

Starts or stops a process.

Input or output

An input is data received by a computer. An output is a signal or data sent from a computer.

Process

An instruction or a command.

Decision

A decision, either yes or no. For example, a decision based on temperature that turns a central heating system on or off.

Line tool

Connects the symbols. The arrow indicates direction.