Sunday, 8 January 2012

Episode 14 : Function Definition


Function Definition

When we use function in the program,  the identifier is called the function definition. This is declare that what kind of statement will be execute in this function.

Function has two main part – function header and function body.

data_type function_name (parameter or argument  list)
header
{
     statement ;
}

body


Function Header : It has three parts –
* Function Name : Function name is defined by the programmer like define the variable name. The rule of define name are same of both variable and function. Keywords are not applicable for function name like variable. We use the letter and underscore between the two or more words. One condition is always  remember that don’t use the same name of library function to user-define function. Example : pay_roll(), student_data(), Printf() [printf() is library function. Difference is cases.] etc.

* Parameter or argument :  Parameter is a general variable of function and it is define in the first bracket of the function. Generally we use this parameter for passing the data from one function to another function and the parameter is work as local variable of that function.  Argument is a value of the parameter which is define in an another function. When a function has a parameter and it is called from another function then call that function with a parameter value as known argument. Argument define in the first bracket when the function is called.

* Return type : We know that when we declare a variable with data type, The same process we use in function. We declare the data type of the function for telling the compiler what type of data it pass.

Example :

 
Output :

I hope you are all understand that operation.

Written by “Shojib”

No comments:

Post a Comment