teach-ict.com logo

THE education site for computer science and ICT

Routine

Often called a 'subroutine' or a 'function'.

Many computer programs are divided up into smaller parts called 'subroutines' or 'functions'.

The main program code calls these subroutines or functions to carry out a specific task - perhaps printing a file and so on.

Subroutines often have values passed into them in order to carry out their task and they may also return values. A typical piece of code looks like

money = work_out_tax(income, tax_rate);

Where the subroutine is 'work_out_tax'

An important difference between a subroutine and a function is that a subroutine can affect global variables whilst functions cannot (should not).

So a function carries out a calculation and returns a value

x = Cos(y)

Just like a calculator a function returns a specific number after pressing any number of function buttons.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Routines