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:

  1. The program reads a “function call”.
  2. The program goes inside the function.
  3. All instructions inside the function are executed in order.
  4. The program exits the function and goes back to the line where it encountered the function call.
  5. The data returned by the function is used in the program further.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.