Procedures

As you move through your lessons on programming you will find that you use more subroutines to save yourself time. As programmers it means we write fewer lines of code, which is brilliant but it also saves the computer time and effort too.

Programming Procedures

The great thing about a subroutine is that the computer doesn’t have to assign any memory to it until the program uses the code, and when the subroutine is over any memory that was used is recycled freeing up the space for something else.

At GCSE we study procedural programming and so the only two subroutine types that we need to be concerned about are procedures and functions. All subroutines are a block of code that has a name and sits outside of the main program – procedures use this technique to perform a task that doesn’t need to send any data back.

Imagine that you have been asked to tidy your room – you don’t need to report back on the success of the task, or send back the percentage of the room that is now tidy, it just needs to get done. In the same way, a procedure completes a task and then the program carries on. In pseudocode, this might look like:

PROCEDURE seeMenu()

    OUTPUT “Please choose an option:”

    OUTPUT “A: Deutsch”

    OUTPUT “B: English”

    OUTPUT “C: Espanol”

END PROCEDURE

Note that here, there is no place to input or any validation. But this procedure will also never run until we add the line seeMenu() to the main code, and that’s because subroutines are like dogs and don’t run until they are ‘called’.

Where next? Try reading about Functions, or make your Subroutines even better with Parameters.

More For Members

Lesson Plan

Coming Soon!

Presentation

Coming Soon!

Homework

Coming Soon!

Not a member yet? Sign Up Here