Advantages of User Defined Function
Single list of instructions within
main() functions are known as monolithic program – i.e. program containing a large single list of instructions.
These types of programs are very difficult to understand, debug, test and maintain. So to avoid these difficulties we use user defined functions.
User defined functions in C programming has following advantages:
- Reduction in Program Size: Since any sequence of statements which are repeatedly used in a program can be combined together to form a user defined functions. And this functions can be called as many times as required. This avoids writing of same code again and again reducing program size.
- Reducing Complexity of Program: Complex program can be decomposed into small sub-programs or user defined functions.
- Easy to Debug and Maintain : During debugging it is very easy to locate and isolate faulty functions. It is also easy to maintain program that uses user defined functions.
- Readability of Program: Since while using user defined function, a complex problem is divided in to different sub-programs with clear objective and interface which makes easy to understand the logic behind the program.
- Code Reusability: Once user defined function is implemented it can be called or used as many times as required which reduces code repeatability and increases code reusability.