Advantages of Functions:


C like many other programming languages provides the ability to break up a program into segment, each of which can be written more or less independently of others. These segments are known as functions. Each function performs a specific, well defined job. The overall control of sequences of operations in the program is managed by one module called main(). The following are the advantages of using functions in a program:
1.      Functions support modular programming in which a large program is divided into smaller self contained         parts, each of which has a unique identifiable purpose. This helps in making the program easier to write,         understand, debug and maintain.
2.      Function result in reducing the overall size of the program as repetitive set of instructions are written only       once in the function. Thus instead of writing, debugging and compiling the same set of instructions again         and again, the same code can be reused.
3.      Designing large and complex programs become very easy and fast using functions. This is because                 different persons can be involved in making different functions which can be later combined to make the         complete program. Thus it results in reduction of time and cost.
4.      Functions promote portability since functions written are independent of system dependent feature.

5.      In C, a function can call itself again, this is known as recursion. Using recursion many calculations can be       done very easily. For example, calculating factorial of a number using recursion.

Previous                                                                                    Next


Powered by Blogger.