A parameter is a piece of data passed to a Function. If a function uses arguments then the variables must be declared in the header of function definition to receive the values. There are two types of arguments/ parameters:
- Formal Parameters
- Actual Parameters
Formal Parameters
The parameters used in the header of function definition are called formal parameters of the function. These parameters are used to receive values from the calling function.
Actual Parameters
The parameters used in the function call are called Actual Parameters. These are the actual values that are passed to the function. The actual parameters may be in the form of constant values or variables. The data types of actual parameters must match with the corresponding data types of formal parameters (variables) in the function definition.
Difference between Formal and Actual Parameters / Arguments
Formal Parameters | Actual Parameters |
---|---|
They are used in the function header. | They are used in the function call |
They are used to receive the values that are passed to the function through function call. | They are actual values that are passed to the function definition through the function call. |
They are treated as local variables of a function in which they are used in the function header. | They can be constant values or variable names (such as local or global). |