Actual and Formal Parameters
User-defined Function:
User-defined is a function that is not part of a library but is defined by the user itself.
Actual Parameters:
Values that are passed to the called function from the main function are known as Actual parameters.
Actual parameters are also called "Arguments".
Formal Parameters:
The variables declared in the function prototype or definition are known as Formal parameters.
Example:
Actual parameters:
void main()
{
int a=5, b=6;
add(a, b);
}
Here "a" and "b" are actual parameters in the call add(a, b).
Formal parameters:
void add(int x, int y)
{
printf("Addition is = %d",(x+y));
}
Here "x" and "y" are formal parameters in the statement void add(int x, int y).
When a method is called, the formal parameter is temporarily "bound" to the actual parameter.
Drafted on 🌏 by,
Jal
☮
peace
Comments
Post a Comment