Function definition

Function definition: function definition contains the statements which we want to perform some specific task according to requirement.

Syntax:           

return-type function-name(parameters)

{

Variable declaration;

Statement1;

—————

—————

Return statement;

}

Function definition contains the following elements:

a.Function name

b.Return type

c.parameters

d.Function body

a.      Function name: The function name is the simply name of the function. It can be any name but it not must be from the reserve words.

b.      Return type: In the return type we have to specify which value should return by the function after its execution.

c.       Parameters: parameters are those values which contain the data for the statements which are in the body of the function.

d.      Function body: The block of the curly braces is called function body. The function body contains the variable declaration, statements and a return statement.

 e.g       int display(int a, int b)

{

int sum;

sum=a+b;

return(sum);

}

Posted in C

Leave a Reply

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