Functions

Functions are used for two purposes in C: It is best not to confuse these two unnecessarily.

We have already seen the format of the special function main. All functions share this format.

Similarities include:

Functions are called by giving their name, with parameters in parentheses where required.

When functions are called the actions associated with them in their declaration are performed.

There is one important difference, however, in functions with a non-void type. A value, of the type associated with that function, is generated by its call. Thus functions calls may be used as expressions. A function call is still a statement. if it returns a value, since an expression may be used as a statement.


Exercises on this section.


Next - Declaring functions.

Back to Contents page.