- How are arrays passed as parameters between functions?
Arrays are always passed between functions as reference parameters.
- How is a single dimensional array passed as a function parameter?
A single dimensional array is passed as a function parameter as follows:
- In the function declaration, the array type is a followed by a pair of brackets.
-
In the function definition heading, the array type is followed by a formal parameter identifier and a
pair of brackets.
- In the function call, only the actual parameter identifier is needed.
- How are two dimensional arrays actually stored?
A two dimensional array is actually stored linearly by row.
-
As a result of the actual manner in which two dimensional arrays are stored, what information must be passed
when using arrays as parameters to insure correct data access?
A two dimensional array is passed as a function parameter as follows:
-
In the function declaration, the array type is followed by a pair of brackets for each dimension of the
array.
-
In the function definition heading, the array type is followed by a formal parameter identifier and
each dimension of the array is denoted by a pair of brackets delimiting the maximum value for the
dimension.
The maximum value of the second dimension must be specified to insure proper access of data.
- In the function call, only the actual parameter identifier is needed.
-
What do you need to do if you want to manipulate the values of an array used as a function parameter but
need to preserve the integrity of the original values?
To preserve the integrity of the values of the original array, make a copy of the array before passing
the array as a parameter.
|