| Call by value |
Call by reference |
| Values of actual parameters are copied to formal parameters. |
Reference of actual parameters is passed to formal parameters. |
| Changes made to formal parameters are not reflected back to actual parameters. |
Changes made to formal parameters are reflected back to actual parameters. |
Difference between call by value and call by reference:
- Call by value: A copy of the actual parameter is passed to the function. Changes made to the parameter inside the function do not affect the original argument.
- Call by reference: A reference to the actual parameter is passed to the function. Changes made to the parameter inside the function affect the original argument.