We have started our discussion with a single dimension array in our previous section. Single dimension array is the simplest form and there can be more than one dimensions. Lets take an exaple of a physical object. Suppose it is wire or rope. It only has a single dimension which is length. Our second case is a rectanguler shaped paper. It has length in two directions. One is length and another is width. This is 2D or two dimensional object. Now take an another case of a book. It has length, width and a thichness. So there are three dimensions thus it is a 3D object. Same dimension rule is applicable for our C array also. Earlier we discussed single dimension array. It has 0 �(n -1) elemnents. Now take one example int_array [row][col] . Here array has two dimension or it is of array type 2D. Here each row has a range of 0 � (col -1) elements and n row can have a range from 0 � (row -1). So total elements are (row x col). Now take a case of 3D array- int_array [height][row][col]. Here we have a 2D planes each having a size of row x col starting from 0 � (height -1). 2D array are often used in matrix calculation. Lets say we have two 2D array and we want to add this and show this result. Initializing 1D array:
Int_array[<size>] = { <value1>, <value2>, ..};
Initializing 2D array:
Int_array[<row size>][<col size>] = {{ <value1>, <value2>, ..}, { <value1>, <value2>, ..}, � };

/* 4x3 Matrix addition using 2D array */
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int a, b,c, val;
int i, j;
printf ("Ener elements for matrix A\n");
for (= 0 ; j < 4; j++) {
for (= 0; i < 3; i++) {
printf ("A [%d][%d] = ", j, i);
scanf ("%d", &val);
a [j][i] = val;
}
}
printf ("Ener elements for matrix B\n");
for (= 0 ; j < 4; j++) {
for (= 0; i < 3; i++) {
printf ("B [%d][%d] = ", j, i);
scanf ("%d", &val);
b [j][i] = val;
}
}
printf ("Matrix A\n");
for (= 0 ; j < 4; j++) {
for (= 0; i < 3; i++) {
printf ("%.2d ", a[j][i]);
}
printf ("\n");
}
printf ("Matrix B\n");
for (= 0 ; j < 4; j++) {
for (= 0; i < 3; i++) {
printf ("%.2d ", b[j][i]);
}
printf ("\n");
}
printf ("Matrix A + B\n");
for (= 0 ; j < 4; j++) {
for (= 0; i < 3; i++) {
c[j][i] = a[j][i] + b[j][i];
printf ("%.2d ", c[j][i]);
}
printf ("\n");
}
return 0;
}
```Output:
Ener elements for matrix A
A  = 1
A  = 2
A  = 3
A  = 4
A  = 5
A  = 6
A  = 7
A  = 8
A  = 9
A  = 10
A  = 11
A  = 12
Ener elements for matrix B
B  = 13
B  = 14
B  = 15
B  = 16
B  = 17
B  = 18
B  = 19
B  = 20
B  = 21
B  = 22
B  = 23
B  = 24
Matrix A
01  02  03
04  05  06
07  08  09
10  11  12
Matrix B
13  14  15
16  17  18
19  20  21
22  23  24
Matrix A + B
14  16  18
20  22  24
26  28  30
32  34  36
```