# 123

Function definition

• The function definition is a set of statements written to perform a specific task.
• The function definition helps us to specify what and how the operation is performed.
• The definition of the function is not terminated by semicolon.
• The function definition can be given either above or below the calling function (main function).
• If the definition of the function is given above the calling function [main ()] then giving function declaration becomes optional.

Syntax:
return_type function_name(list of arguments)
{
statements
return(value/variables/expression);
}

Example:

No pass No return
void abc()
{
statements;
statements;
}
void xyz()
{
Statement;
}
Pass and no return
void abc(int x,int y)
{
Statements;
Statements;
}
void xyz(float z,float b)
{
Statements;
Statements;
}
pass and return
int abc(int a,int b)
{
Statements;
Statements;
return(value/variable/exp);
}
float xyz(int a,int b)
{
Statements;
Statements;
return(value/variable/exp);
}
no pass and return
int abc()
{
Statements;
Statements;
return(value/variable/exp);
}
float xyz()
{
Statements;
Statements;
return(value/variable/exp);
}

### NO PASS NO RETURN

In no pass no return, no value is passed from the calling function to the called function and no value is returned back from the called function to the calling function.

### PASS AND NO RETURN

In Pass and no return, value(s) are passed from the calling function to the called function but no value is returned back from the called function to the calling function.

### PASS AND RETURN

In Pass and Return, value(s) is/are passed from the calling function to the called function and a value is returned back from the called function to the calling function.

Note:

• A function can return a maximum of one value.
• There can be any number of return statements in a function but as soon as any one of return the statement gets executed the control goes back to the calling function.

### No pass and return

In No Pass and Return, no value is passed from the calling function to the called function but a value is returned back from the called function to the calling function.

Function Page :3

Important Pages