Professional Documents
Culture Documents
Abhineet Anand
Declaration
Introduces the function name, function return type, and function
parameters to the program.
The function body (statements)is not part of the declaration
A function must be declared before it is used
Declaration
Introduces the function name, function return type, and function
parameters to the program.
The function body (statements)is not part of the declaration
A function must be declared before it is used
return_type function_name(parameter_list);
parameter_list: type param1,type param2,type param3, etc
double sqrt(double);
int func1();
Abhineet Anand Function
Function Definition
Function Definition
Function Definition, also known as function implementation, means
composing a function. Every Function defination consists of two Parts:
Header of the function,
Body of the function.
Function Definition
Function Definition, also known as function implementation, means
composing a function. Every Function defination consists of two Parts:
Header of the function,
Body of the function.
return_type function_name(parameter_list){
// Function body }
Function Definition
The general form of header of a function is:
[return_type] function_name([parameter_list])
The header of function is not terminated with a semicolon.
The body of a function consist of a set of statements enclosed
within braces.
The return statement is used to return the result of the computations
done in the called function and/or to return the program control back
to the calling function.
A function can be defined in any part of the program text or within a
library.
Function Invocation/call/Use
Depending upon their inputs (i.e. parameters) and outputs, functions are
classified as:
Function with no input-output.
Function with inputs and no output.
Function with input and one output.
Function with input and output.
return statement
The return statement is used to return the result of the computations
performed in the called function and/or transfer the program control
back to the calling function.
There are two forms of the return statement:
1 return,
2 return expression.
Abhineet Anand Function
Function with Input and One Output