Parallel and Multi-Dimensional Arrays Some programs require the use of multiple arrays or multi-dimensional arryas. You will learn to use them and the sizeof operator to calculate the size of arrays and other data structures. Parallel Arrays are used to store data in a tabular form with columns and rows. Using parallel arrays, each data in a column can be stored in a separate array with subscripts. They are called parallel because the same subscript can access any data for a given row. You will see a simple for loop which can print the table to the screen using the same index variable for each array. Parallel Arrays can consist of different data types. The data can be stored in an array of floats and a parallel array of ints. Multi-Dimensional Arrays is an alternative to a parallel array. Using a multi-dimensional array a single identifier, and all of the values can be stored with the same data type. All elements of a two-dimensional array must be the same data type. When a table of shipping rates is placed in a two-dimensional array, the rows and columns of the table become subscripts of the array. For example ship_rate[2][3] points to the value at the intersection of the third row and the fourth column. Because array subscripts begin at zero, the third row is identified with the subscript 2, and the fourth column is identified with the subscript 3. Declaring the ship_rate array is simple. The two dimensions, however, make initializing the array more difficult. The array is declared by providing two subscripts in the declaration. The first subscript declares the number of the rows, and the second subscript declares the number of columns. float ship_rate[6][8]; To initialize the array when you declare it, you must make use of additional braces to group the values into rows. Each row of the data is enclosed in a set of braces and followed by a comma. float ship_rate[6][8] = { { 2.65, 2.75, 2.85, 2.33, 3.33, 4.33, 4.55, 5.33 } { five more rows of 8 data items} }; Your compiler will allow you to declare arrays of three, four, or even more dimensions. These kinds of arrays are less common than two-dimensional arrays, but can be declared by simply adding more subscripts to a declaration. You should keep the size of arrays in mind when declaring multi-dimensional arrays. There is a limit. You can calculate the size of an array by multiploying the number of elements by the size of the data type used. For example, the declaration below declares a two-dimensional array that is 50 by 10, or 500 elements. Because the array is of type long double, each element occupies ten bytes. Therefore the array occupies a total of 5000 bytes of memory. long double t[50][10]; The sizeof operator is used for calculating the size of arrays and other data structures. The statement below assigns the number of bytes occupied by the character array address to the variable size_of_address. size_of_address = sizeof(address); The sizeof operator will also return the size in bytes of any variable. =============== Assignment 11-2: Write a program that asks the user for his or her name and stores it in a character array. The program should then print the user's name to the screen by dividing the characters between lines and presenting them diagonally as in the example below: B r i a n D a v i s Assignment 11-3: Write a program that pits the user against the computer in a game of tic-tac-toe. Use characters in the ASCII table to display the progress of the game. Assignment 11-4: Write a program that implements two mathematical matrices as two-dimensional arrays and uses the rules of algebra to multiply one matrix by the other. The output should be placed in a third matrix. The data for each element of the third matrix is derived by multiplying the values of the corresponding elements in the first two matrices.