Hello guys , today in this my post i will tell you some basic rule of function declaration and how many types of variable we use in function .
Rule of function variable:
- Find declaration needs to be ended using semicolon.
- Return type is optional.
- Type of parameter & number of parameter are combings called parameter list. The parameter C in the list may or may not have parameter name.
- No parameter can have some names even parameter name and function name cannot be same.
- A function need not be declared if it is defined before it is called.
Ex. Void add ( int , int )
The above declaration declare a function name and with two parameter of type of int and return type of void ( function does not return ).
Function header is same as function declare but without a semicolon,It consist of return type , function name , parameter type and no. of parameter.
Variable:
There are two types of variable in function-
- Local variable
- Global variable
Local variable:
It is a variable that is defined inside a function and can not be used outside that function.
Global variable:
It is a variable that are declare outside any function and where values can be used in any function without posting it to any function.
Parameter:
Parameter are used to pass values to called function and are also use to receive values from calling function.There are three type of parameter
- Formal parameter
- Actual parameter
Actual parameter:
Actual parameter are those parameter which have the original copy of parameters. The parameter passed in the function call are called actual parameter.Scope of actual parameter are only with in called function.
Formal parameter:
Formal parameter are those parameter which have duplicate copy of parameter.The parameter in function header as called formal parameter ( scope is within called function).
Comments
Post a Comment