Function declaration, Function definition and Function call in C program | Coding classpoint

Function declaration: 

Function declaration, Function definition and Function call in C program | Coding classpoint

Function declaration is also known as function prototype. It inform the compiler about three thing, those are name of the function, number and type of argument received by the function and the type of value returned by the function. 

While declaring the name of the argument is optional and the function prototype always terminated by the semicolon.

Function definition:

Function definition consists of the whole description and code of the function. It tells about what function is doing what are its inputs and what are its out put It consists of two parts function header and function body .

Syntax:

return type function(type 1 arg1, type2 arg2, type3 arg3) /*function header*/ 
 { 
 Local variable declaration; 
 Statement 1; 
 Statement 2; 
 Return value
 } 

The return type denotes the type of the value that function will return and it is optional and if it is omitted, it is assumed to be int by default. The body of the function is the compound statements or block which consists of local variable declaration statement and optional return statement.

The local variable declared inside a function is local to that function only. It can’t be used anywhere in the program and its existence is only within this function. 

The arguments of the function definition are known as formal arguments. 

Function Call 

When the function get called by the calling function then that is called, function call. The compiler execute these functions when the semicolon is followed by the function name.

Example:

function(arg1,arg2,arg3); 

The argument that are used inside the function call are called actual argument

int S=sum(a, b); //actual arguments


Tags

Post a Comment

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