Function
Modules
in ‘C’ are functions. A function is a self contained block of statements that
perform a specific task of some king. Every
‘C’ program is a combination of one or more functions.
Main
is also a function with a reserved name, main()
A
common analogy for the concept of functions is the hierarchical form of
management.
A
boss (the calling function or caller) asks a worker (the called function) to
perform a task and report back, when the task is done.
The
worker may call for other worker functions, and the boss will be unaware of
this.
Note,
that worker1 acts as a boss function to worker4 and worker5.
Relationships
among functions may differ from the hierarchical structure shown in the above
figure.
Similarly,
the main function communicates with several worker functions in a hierarchical
manner.
For
example, a function needing to display information on the screen, calls the
worker function ‘printf’ to perform the task, then printf displays the information
and reports back or returns to the calling function, when its task is
completed.