Function In C Program - Library function and User defined function | Coding classpoint

FUNCTION



A function is a self contained block of codes or sub programs with a set of statements that perform some specific task or coherent task when it is called. 

It is something like to hiring a person to do some specific task like, every six months servicing a bike and hand over to it. 

Any ‘C’ program contain at least one function i.e main().

There are basically two types of function those are 

                             1. Library function 
                             2. User defined function

The user defined functions defined by the user according to its requirement System defined function can’t be modified, it can only read and can be used. 

These function are supplied with every C compiler Source of these library function are pre complied and only object code get used by the user by linking to the code by linker.


Here in system defined function description:

Function definition : predefined, precompiled, stored in the library

Function declaration : In header file with or function prototype. 

Function call : By the programmer

User defined function

Syntax

Return type name of function (type 1 arg 1, type2 arg2, type3 arg3) 
Return type function name argument list of the above syntax

So when user gets his own function three thing he has to know, these are

  •                         Function declaration 
  •                         Function definition 
  •                         Function call

These three things are represented like 

 int function(int, int, int); /*function declaration*/ 

 main() /* calling function*/
 
 { 

 function(arg1,arg2,arg3); 

 } 

 int function(type 1 arg 1,type2 arg2,type3, arg3) /*function definition/* 

 { 

 Local variable declaration; 

 Statement; 

 Return value; 

 } 
Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.