Thursday 18 November 2010

Distinguish between actual and formal parameters

1.       Distinguish between actual and formal parameters?

Ans: these are the function 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

No comments:

Post a Comment