Next: void functions Up: Programming in C Previous: Exercises

Functions

C provides functions which are again similar most languages. One difference is that C regards main() as function. Also unlike some languages, such as Pascal, C does not have procedures - it uses functions to service both requirements.

Let us remind ourselves of the form of a function:

Let us look at an example to find the average of two integers:

Note: The return statement passes the result back to the main program.



Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994