Multidimensional array An array of arrays known as multidimensional array. Two dimensional (2 D) arrays • An array of array is known as 2 D array. • The two dimensional (2 D) array in C programming is also known as matrix. • A matrix can be represented as a table of rows and columns.
Two dimensional (2 D) arrays float x[3][4]; Here, x is a two-dimensional (2 d) array. The array can hold 12 elements.
Accessing Two-Dimensional Array Elements An element in a two-dimensional array is accessed by using the subscripts, i. e. , row index and column index of the array. For example int val = x[2][3];
How to initialize a Two-Dimensional Array • There is more than one way to initialize a multidimensional array.
How to initialize a Two-Dimensional Array IF What is output?
Example program on Two-Dimensional Array
Example program on Two-Dimensional Array
Three-Dimensional Array Similarly, you can declare a three-dimensional (3 d) array float y[2][4][3]; Initialization of a three dimensional array in a similar way like a two dimensional array. Initialization of a three dimensional array. You can initialize a three dimensional array in a similar way like a two dimensional array. Here's an example, int test[2][3][4] = { { {3, 4, 2, 3}, {0, -3, 9, 11}, {23, 12, 23, 2} }, { {13, 4, 56, 3}, {5, 9, 3, 5}, {3, 1, 4, 9} } }
Three-Dimensional Array
Assignments • Write a C program for addition of two matrices • Write a C program for multiplication of two matrices • Write a C program for transpose of a matrices • Write a sample program on 3 D arrays. And perform addition of two 3 D arrys