A function is a block of code that performs a specific task. It is a group of statements that together perform a task.
In this tutorial, you will be introduced to functions (both user-defined and standard library functions) in C programming.
In C, we can divide a large program into the basic building blocks known as function.
The function contains the set of programming statements enclosed by {}.
Dividing a complex problem into smaller chunks makes our program easy to understand and reuse.
A function can be called multiple times to provide reusability and modularity to the C program.
Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. The execution of a C program begins from the main()
function.
Types of function
There are two types of function in C programming as mentioned below.
- Standard library functions
- User-defined functions
Standard library functions
The standard library functions are built-in functions in C programming.
These are the functions which are declared in the C header files such as scanf(), printf(), gets(), puts(), ceil(), floor() etc.
User-defined function
These are the functions which are created by the C programmer.
This is just an overview of functions. You will learn everything about functions in C in next chapters of this tutorial.