Wednesday 8 December 2010

function defenition




return_type  function_name(parameters)
{
  function body
}

Function Heading:

1. in the above syntax, first line is called function heading
2. function heading should be identical to function prototype with the exception of semicolon
 arguments(formal parameters) are to be specify here.



return_type:

1. return_type is type of value is returned by function
2. return_type may be void if the function is not returning any value

function_name:
1. it is any unique identifier (u can give any name for the function name)

parameters:

1. comma seperated list of types and names of parameters
2. parameters takes the values to the function on which function is going to operate
3. parameter field is optional
4. if no parameter is passed , then no need to write this field

function body:

the first line (i.e return-type function-name(parameters) is called as function heading and the statement within curly braces is called function body

the function body contains the declarations and the statemnet for performing the necessary operation.
the body is enclosed within curly breaces {} and it contains 3 parts

1. local varialbe declaration.
2. function statement that performs the operation(task) of the function
3. a return statement

return value: or Return statement

1. it is value return by the function upon termination
2. function will not return a value if the function is void.
more expalnation about the  Return statement

 Functions

No comments:

Post a Comment