Introduction
Learn how to use functions in your program.
We'll cover the following
Definition
A function is a self-contained block of statements that perform a particular task.
Every C program is a collection of one or more functions. You can even call a function from another function using parameters and use its results to perform numerous tasks.
Workflow
When a function is called, the program leaves the current line’s execution and continues the execution from the first line inside the called function. The flow of control of a function is given below:
- The program reads a “function call”.
- The program goes inside the function.
- All instructions inside the function are executed in order.
- The program exits the function and goes back to the line where it encountered the function call.
- The data returned by the function is used in the program further.
Get hands-on with 1400+ tech skills courses.