Function Definition
Introduction to Functions in C
A function is a block containing a number of statements, which perform a specific and well defined task(s). Every function has a unique name which is sued to identify it in a program. Once a task is packaged in a function, it can be called from any where in a program through other statements.
Advantages of function:
- Function reduce the complexity of program by dividing the into smaller modules, thus making them easier to read and debug.
- Function enhance reusability of code and can be called from any where in a program and any number of time.
- Function are useful in hiding the implementation details.
- It is easier to edit a program, which is written using methods. While working on one function, one can focus on just that part of the program by debugging, constructing and making it perfect.
Function can be broadly classified into two categories:
Built-in function or library functions
These are inbuilt function, which are grouped together and stored in a standard library (Header Files). You can make use of these functions to get a predefined output, instead of writing your own code.
User defined Function :
These function are designed by the user to carry out some specific tasks. These name of the function is given by the user according to his/her requirement; hence, it is called a user defined function.