This is a small piece of program, nicely packaged, and put slightly away. Furthermore, this piece won't run unless it is called.
Functions make easy recycling (the function can be called several times from different places), quick fixes (only one place to change the program), and quick change overs (a whole function can be replaced by another).
Here's an example:
function shootAtShip(x,y) if there's a ship at (x,y) mark this ship as hit in (x,y) return 1 else return 0A parameter is input to a function - some functions need input to work. In the example above x and y are parameters.
A function can run and then have a return value, a number e.g. In some cases, it's returned whether everything went all right - 0 = no and 1 = yes e.g., as in the example above.
Concept last updated: 24/09 2003.