REVIEW QUESTIONS ON ARRAYS AS FUNCTION PARAMETERS

Please note that the material on this website is not intended to be exhaustive.
This is intended as a summary and supplementary material.
  1. How are arrays passed as parameters between functions?
  2. Arrays are always passed between functions as reference parameters.

  3. How is a single dimensional array passed as a function parameter?
  4. 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.

  5. How are two dimensional arrays actually stored?
  6. A two dimensional array is actually stored linearly by row.

  7. 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?
  8. 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.

  9. 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?
  10. To preserve the integrity of the values of the original array, make a copy of the array before passing the array as a parameter.


© 1994-07-23 cpsm ; last update 2011-11-25 20:16