Calling a routine
About this lesson: Calling a routine
In short
A procedure is a named group of steps. When the main program calls it, control jumps into the procedure, runs it, then returns to the line after the call. Step through.

What you'll explore
- Procedures: Jump in, run, jump back
- A procedure is a named group of steps.
- Functions: A routine that returns a value
- A function sends a value back. area(4, 5) receives w = 4 and h = 5, returns 20, and the main program stores it. Change the values.
- Why use routines?: Write once, use many times
- Drawing three squares without a routine repeats the same code three times. With a routine it is written once and called three times.
- Check yourself: Where next?
- A program calls a procedure on line 8. The procedure finishes.
Also in this lesson
- Common mix-ups
- Routines
- Dance routine
Words to know
- routine
- A named block of code: a procedure or function.
- procedure
- A routine that performs a task.
- function
- A routine that returns a value.
- parameter
- A variable that receives a value when a routine is called.
- call
- Run a routine by using its name.
Sources
- BBC Bitesize KS3 Computer Science
- Raspberry Pi Foundation, Computing curriculum resources
← Designing an algorithm: flowchart and pseudocode · Count-controlled loops in Python →