The standard library functions are built-in functions in C programming.
These functions are defined in header files. For example,
- The
printf()
is a standard library function to send formatted output to the screen (display output on the screen). This function is defined in thestdio.h
header file.
Hence, to use theprintf()
function, we need to include thestdio.h
header file using#include <stdio.h>
. - The
sqrt()
function calculates the square root of a number. The function is defined in themath.h
header file.
User-defined function
You can also create functions as per your need. Such functions created by the user are known as user-defined functions.
How user-defined function works?
#include <stdio.h> void functionName() { ... .. ... ... .. ... } int main() { ... .. ... ... .. ... functionName(); ... .. ... ... .. ... }
The execution of a C program begins from the main()
function.
When the compiler encounters functionName();
, control of the program jumps to
void functionName()
And, the compiler starts executing the codes inside functionName()
.
The control of the program jumps back to the main()
function once code inside the function definition is executed.

Note, function names are identifiers and should be unique.
Advantages of user-defined function
- The program will be easier to understand, maintain and debug.
- Reusable codes that can be used in other programs
- A large program can be divided into smaller modules. Hence, a large project can be divided among many programmers.