> Online tutorial : function in c
Showing posts with label function in c. Show all posts
Showing posts with label function in c. Show all posts

Declaration of function in c

Declaration of function:

1.function name

2.function type

3.list of parameter

syntax
Function type function_type(parameter list)

Example


int
mul(int m,int n);

function definition in c

Element of user defined function:

1.function definition

2.function call

3.function declaration


Defintion of function

A function definition ,also known as function implememtation shall include the following elements

1.function name

2.function type


3.list of parameter

4.local variable declaration

5.function statement

6.a return type

Syntax

Function type function_type(parameter list)

{

Local variable declaration;

Executable statement1;

Executable statement2;

Return statement;

}

Example:

void add(int a,int b)
{
int c;
return 0;
}


for above the statement

void          - return type
add          -function name
int a,int b  -parameter

function in c

user defined function
Need for user defined function:
As pointed out that main is a specially recongized fuction in c.ever y fuction program must have main function to

indicate where the functionhas to execution has to begin its execution.