Function
è Modularity is one of
the important elements of the c programming. Modularity means partitioning a
complex problem into set of sub-problems which are easily understandable,
manageable and maintainable. The C supports the modularity by allowing user to
write small functions for each of the small problem.
è A function is a routine
or set of instructions that perform a specific task and can be processed
independently. When the program passes control to the function the function
perform that task and returns control to the instructions following the calling
instruction.
è Once the problem is
divided into set of task, a function can be written for each task and by
integrating all such functions , a complete application can be developed
easily.
è A library of functions
can be designed & tested for use of every programmer. There are two type of
function.
1.
Built in or Library function.
2.
User define function.
è The main() function in
every c program is an example of user defined function. while printf(),scanf(),
etc are the library functions.
Advantage of using Function :
è The complex program can
be divided into simple function and then integrate them.
è The sub program is
easier to write understand and debug.
è A function can be
shared by other program by compiling this function separately and loading and linking them together.
è Function is written
once in a program , but used many times which reduces the length of the program
and thus saves the memory.
è In C function can call
itself again it is called a recursive function.
è Subprogram reduces the
size of program .
No comments:
Post a Comment