Question #20192

,explain how pass by reference differs with pass by value method

Expert's answer


Pass By Reference :
In Pass by reference address of the variable is passed to a function. Whatever
changes made to the formal parameter will affect to the actual parameters
- Same memory location is used for both variables.(Formal and Actual)-
- it is useful when you required to return more then 1 values
Pass By Value:
- In this method value of the variable is passed. Changes made to formal will
not affect the actual parameters.
- Different memory locations will be created for both variables.
- Here there will be temporary variable created in the function stack which
does not affect the original variable.
LATEST TUTORIALS
APPROVED BY CLIENTS