parameters are the communication between the calling and called function .
Arguments and parameters refer to the variables or expressions passed from the caller of a function into the function (or macro).
there are two types of parameters
1. actual parameter
2. formal parameter
Distinguish between actual and formal parameters?
argument: that which is passed into a function by its caller (or macro by its invoker)
parameter: that which is received by the function or macro
Functions
Arguments and parameters refer to the variables or expressions passed from the caller of a function into the function (or macro).
there are two types of parameters
1. actual parameter
2. formal parameter
Distinguish between actual and formal parameters?
Actual parameters
|
Formal parameters
|
1. The parameters specified in the function call are called as actual parameters
|
The parameters specified in the function declaration are called formal parameters
|
2. Sending the value or variable or expression from the function call
|
Receiving the value or variable from the actual parameters
|
3. Ex: swap(a,b); or swap(2,3);
Here a,b or 2,3 are actual parameters
|
Ex: void swap(int a, int b)
{
}
Here a,b are formal parameters
|
4. Passing the parameters a,b to swap()
|
Here a,b are receiving the value or variables
|
5. Actual parameters may be variable,value or expression, or structure,address
|
It must be variable or structure or array but not values or expressions
|
argument: that which is passed into a function by its caller (or macro by its invoker)
parameter: that which is received by the function or macro
Functions
No comments:
Post a Comment