A function is a self contained block of program statements that performs a particular task. It is defined as a section of program performing a specific job. A large C program is divided into basic building blocks called C functions. C functions contain set of instructions enclosed in “{ }” which performs specific operations in a C program. Actually, collection of these functions together creates a C program.
Uses of C Functions :
- C functions are used to avoid rewriting of same logic/code again and again in a program.
- There is no limit in calling same C function to make use of same functionality whenever and wherever required.
- A large C program can easily be tracked when it is divided into functions.
- The core concept of C functions are, re-usability, dividing a big task into small and to achieve the functionality and to improve understanding of very large C programs easily.
Types of Functions:
There are two types of functions in C programming
1. Library Functions
2. User Defined Functions
1. Library Functions :
These are the functions which are defined by C library.
Example : printf(), scanf(), strcat()etc. You just need to include appropriate header files to use these functions. These are already declared and defined in C libraries
User Defined Functions :
These are the functions which are defined by the user at the time of writing program. Functions are made for code re-usability and for saving time and space.