Passing Arguments by Value
The arguments to a function may be passed on by value or by pointers. In the first case the copies of values of parameters are passed on to the function. The function can only manipulate these copies. So, the original values of parameters are not affected. Their values cannot be changed by the function because function does not know where the parameters are stored in the memory. For example, if the function simply swapped the values of its parameters, it is only swapping the copies of the values of parameters. The original values of parameters are not affected. In Program, the arguments are passed on to the function by values. These values are changed by the function and then an expression is evaluated. The function may be called any numbers of times, the output of the program as well as the data fed to function do not change. This is the benefit of passing the arguments by value.