Introduction to Functions in C - YouTube
Function in C

Function in C Language

Aoa!

After reading this you will be able to understand the concept of function in c language.

So, at first we will discuss about what a function is.

Function:

A function is a named block of a code that performs some action. The statements written in a function are executed when it is called by its name. Each function has a unique name. Functions are the building blocks of C programs. They encapsulate pieces of code to perform specified operations. The functions are used to accomplish the similar tasks again and again without writing the same code again. They are used to perform the tasks that are repeated many times.

The functions provide a structured programming approach. It is modular way of writing programs. The whole program logic is divided into a smaller modules or functions. The main function calls these functions when they are needed to execute.

Importance of Functions

A program may need to repeat the same piece code at a various places. It may be required to perform certain tasks repeatedly. The program may become very large if functions are not used. The piece of the code that is not executed repeatedly is stored in a separate function. The real reason of using functions is to divide a program into different parts. These parts of a program can be merged easily.

Now we will discuss about the benefits that a function gives its users.

So, following are the benefits given by a function in c language to its users.

  1. Easier to code
  2. Easier to modify
  3. Easier to maintain and debug
  4. Reusability
  5. Less programming time

Easier to Code

It means that a lengthy program can be divided into small functions. It is easier to write small functions instead of writing a long program. A function is written to solve a problem.

Easier to modify

Each function has a unique name and is written as an independent block. If there is any error in the program, the change is made to particular function in which error exists. A small function is easier to modify than a larger program.

Easier to maintain and Debug

Functions are easier to maintain as compared to long programs. Each function contains independent code. A change in the function does not affect other parts of a program. In case of an error, the infected function is debugged only. The user does not need to examine the whole program.

Reusability

The code written in function can be reused as and when required. A function can be executed many times. A function is written to solve a particular problem.

Less programming time

A program may consist of many functions. These functions are written as independent programs. Different programmers can work on different functions at the same time. It takes far less time to complete the program.

Thank you……

Leave a Reply

Your email address will not be published. Required fields are marked *