Introduction to Computing – B142L
Functions
Academic year
2011/12
Objectives:
- Purpose of functions
- Implementation of functions
- Practices to use functions
Groups of statements
In which situations would it be useful to organise statements into a group?
Which methods are available to combine multiple statements into a group?
Output from functions
Which functions in the standard library produce output values?
What is the syntax term for the output values produced by a function?
How do we define the data type for the output value produced by a function?
How do we use the output value produced by a function?
Is it a requirement to use the output value produced by a function?
Is there a minimum or maximum number of output values produced by a function?
Input to functions
Which functions in the standard library require input values?
What is the syntax term for the input values provided to a function?
How do we define the data type for the input values provided to a function?
How do we use the input values provided to a function?
Is it a requirement to use the input values provided to a function?
Is there a minimum or maximum number of input values provided to a function?
Structured programming with functions
The operation of a C program could be described as the transfer of control from one function to another function until the main function is finished.
How could we describe that in a graphical manner?
How does a program know whether a function is available (that it exists) or not?
Where are the input and output values for each function in the diagram?
Structured programming with functions
Functions permit C programs to be organised and designed for:
- Re-use of frequently used code
- Separation of code that have difficult or important logic
- Separation of code for performance or security optimisation
- Split of tasks for collaborative development