0% found this document useful (0 votes)
37 views13 pages

C Multidimensional Arrays Explained

Uploaded by

charakvikhyat1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views13 pages

C Multidimensional Arrays Explained

Uploaded by

charakvikhyat1
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MULTIDIMENSION

ARRAY
C Multidimensional Arrays

◦ In C programming, you can create an array of arrays. These arrays are known as multidimensional arrays.
For example,
◦ float x[3][4];
◦ Here, x is a two-dimensional (2d) array. The array can hold 12 elements. the array is a table with 3 rows
and each row has 4 columns.
Three-dimensional (3d)
◦ Similarly, declare a three-dimensional (3d) array. For example,

◦ float y[2][4][3];
◦ Here, the array y can hold 24 elements.
Initializing a multidimensional array

◦ Initialization of a 2d array
◦ // Different ways to initialize two-dimensional array

◦ int c[2][3] = {{1, 3, 0}, {-1, 5, 9}};



◦ int c[][3] = {{1, 3, 0}, {-1, 5, 9}};

◦ int c[2][3] = {1, 3, 0, -1, 5, 9};
Initialization of a 3d 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}}};
Sum of two matrices
Three-dimensional array

You might also like