Function in C Language

Posted on

C Operate


Operate in C Language


A operate is a gaggle of statements that collectively carry out a selected job. Each C program has no less than one operate, which is fundamental().

function - Function in C Language

Why use operate ?

Operate are used for divide a big code into module, as a result of this we are able to simply debug and preserve the code. For instance if we write a calculator applications at the moment we are able to write each logic in a separate operate (For addition sum(), for subtraction sub()). Any operate will be referred to as many occasions.

Benefit of Operate

  • Code Re-usability
  • Develop an software in module format.
  • Simply to debug this system.
  • Code optimization: No want to put in writing lot of code.

Kind of Operate

There are two sort of operate in C Language. They’re;

  • Library operate or pre-define operate.
  • Consumer outlined operate.

function type - Function in C Language

Library operate

Library capabilities are these that are predefined in C compiler. The implementation a part of pre-defined capabilities is out there in library information which are .lib/.obj information. .lib or .obj information are contained pre-compiled code. printf(), scanf(), clrscr(), pow() and so on. are pre-defined capabilities.

Limitations of Library operate

  • All predefined operate are contained restricted job solely that’s for what goal operate is designed for identical goal it ought to be used.
  • As a programmer we don’t having any controls on predefined operate implementation half is there in machine readable format.
  • In implementation at any time when a predefined operate just isn’t supporting consumer requirement then go for consumer outlined operate.

Consumer outlined operate

These capabilities are created by programmer based on their requirement for instance suppose you need to create a operate for add two quantity then you definitely create a operate with title sum() any such operate known as consumer outlined operate.

Defining a operate.

Defining of operate is nothing however give physique of operate which means write logic inside operate physique.


  • Return sort: A operate might return a worth. The return_type is the info sort of the worth the operate returns.Return sort parameters and returns assertion are non-compulsory.
  • Operate title: Operate title is the title of operate it’s determined by programmer otherwise you.
  • Parameters: It is a worth which is move in operate on the time of calling of operate A parameter is sort of a placeholder. It’s non-compulsory.
  • Operate physique: Operate physique is the gathering of statements.

Operate Declarations

A operate declaration is the method of tells the compiler a couple of operate title. The precise physique of the operate will be outlined individually.


Notice: On the time of operate declaration operate should be terminated with ;.

calling a operate.

After we name any operate management goes to operate physique and execute whole code. For name any operate simply write title of operate and if any parameter is required then move parameter.


Notice: On the time of operate calling operate should be terminated with ‘;’.

Instance of Operate