|
|
|
|
|
|
|
5. When declaring a multidimensional array as a formal parameter, you must state the sizes of all but the first dimension. Also, these sizes must agree exactly with the sizes of the caller's actual parameter. |
|
|
|
|
|
|
|
|
6. To eliminate the chances of size mismatches referred to in item 5, use a Typedef statement to define a multidimensional array type. Declare both the actual parameter and the formal parameter to be of this type. |
|
|
|
|
|
|
|
|
Two-dimensional arrays are useful for processing information that is represented naturally in table form. Processing data in two-dimensional arrays usually takes one of two forms: processing by row or processing by column. An array of arrays, which is useful if rows of the array must be passed as parameters, is an alternative way of defining a two-dimensional array. |
|
|
|
|
|
|
|
|
A multidimensional array is a collection of like components, ordered on more than one dimension. Each component is accessed by a set of indices, one for each dimension, that represents the component's position on the various dimensions. Each index may be thought of as describing a feature of a given array component. |
|
|
|
|
|
|
|
|
Data structures should be selected to reflect accurately the relationships inherent in the data values themselves. Two-dimensional arrays and parallel arrays can be used to hold the same data. An analysis of what the data mean can help you make the appropriate choice. |
|
|
|
|
|
|
|
|
1. Declare a two-dimensional array, named plan, with 30 rows and 10 columns. The component type of the array is float, (pp. 708712) |
|
|
|
|
|
|
|
|
2. Assign the value 27.3 to the component in row 13, column 7 of the array plan from Question 1. (pp. 708712) |
|
|
|
|
|
|
|
|
3. Nested For loops can be used to sum the values in each row of array plan. What range of values would the outer For loop count through to do this? (pp. 714716) |
|
|
|
|
|
|
|
|
4. Nested For loops can be used to sum the values in each column of array plan. What range of values would the outer For loop count through to do this? (pp. 716717) |
|
|
|
|
|
|
|
|
5. Write a program fragment that initializes array plan from Question 1 to all zeros. (pp. 717718) |
|
|
|
|
|
|
|
|
6. Write a program fragment that prints the contents of array plan, one row per line of output. (pp. 718720) |
|
|
|
|
|
|
|
|
7. Suppose array plan is passed as a parameter to a function in which the corresponding formal parameter is named someArray. What would the declaration of someArray look like in the formal parameter list? (pp. 720722) |
|
|
|
|
|