Following are the differences between a call by value and call by reference are:
| |
Call by value |
Call by reference |
| Description |
When a copy of the value is passed to the function, then the original value is not modified. |
When a copy of the value is passed to the function, then the original value is modified. |
| Memory location |
Actual arguments and formal arguments are created in separate memory locations. |
Actual arguments and formal arguments are created in the same memory location. |
| Safety |
In this case, actual arguments remain safe as they cannot be modified. |
In this case, actual arguments are not reliable, as they are modified. |
| Arguments |
The copies of the actual arguments are passed to the formal arguments. |
The addresses of actual arguments are passed to their respective formal arguments. |