A. Introduction
We discussed the scope of local variables in 7.6. A local variable is only visible in the function/method where it is declared. But what happens to function/method parameters which are defined in the caller method but their values are passed to another function as inputs? Obviously, these parameters are visible in the caller function, but what happens when their values are passed to the called function? Will the changes made in the called function be returned to the caller?
As a matter of fact, passing individual variables and passing arrays are a bit different. When passing individual variables, copies of variable values are passed to the called methods as inputs; but when the parameters are arrays, references of the arrays are passed to the called methods, which may result in completely different outcomes.
B. Watch (PPT)
C. Try:
Create a function to return the maximum value of an int array
Create a function to save the maximum value of an int array as its first element, while the rest values are still saved in the same array.