Multidimensional Array in C Language

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

In C programming language, a multidimensional array is an array that contains more than one dimension. The most common types of multidimensional arrays are two-dimensional and three-dimensional arrays.

A two-dimensional array is an array of arrays, where each element in the array is an array of elements. Here is an example of how to declare and initialize a 2D array in C:

Copy code

int array2D[3][4] = {    {1, 2, 3, 4},    {5, 6, 7, 8},    {9, 10, 11, 12} };

In this example, array2D is a 2D array with 3 rows and 4 columns. The elements of the array can be accessed using the indices of the rows and columns, for example:

Copy code

printf("%d", array2D[1][2]);  // Prints 7

A three-dimensional array is an array of arrays of arrays, where each element in the array is an array of arrays. Here is an example of how to declare and initialize a 3D array in C:

Copy code

int array3D[2][3][4] = {    {        {1, 2, 3, 4},        {5, 6, 7, 8},        {9, 10, 11, 12}    },    {        {13, 14, 15, 16},        {17, 18, 19, 20},        {21, 22, 23, 24}    } };

In this example, array3D is a 3D array with 2 planes, 3 rows and 4 columns. The elements of the array can be accessed using the indices of the planes, rows and columns, for example:

Copy code

printf("%d", array3D[1][2][3]);  // Prints 24

It's important to note that when you declare a multidimensional array, you must specify the size of each dimension, and that the size of the first dimension is the number of elements in the second dimension and so on.

11. Multi Dimensional Array

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?