In this tutorial you will learn about the Multi-dimensional Array and its application with practical example.
Multi-dimensional array
Multi-dimensional arrays is nothing just an array of arrays. We can declare a multidimensional array, as below:
Syntax:-
1 |
type arrayName[size][size2][size3]… |
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> int main() { int i,j; // declaring and Initializing array int arr[2][2] = {10,20,30,40}; for (i=0;i<2;i++) { for (j=0;j<2;j++) { // Accessing variables printf("value of arr[%d][%d] is %d\n",i,j,arr[i][j]); } } } |
Output:
1 2 3 4 |
value of arr[0][0] is 10 value of arr[0][1] is 20 value of arr[1][0] is 30 value of arr[1][1] is 40 |