multidimensional array in c code example

Example 1: how to declare multidimensional array in c

int a[3][4] = {  
   {0, 1, 2, 3} ,   /*  initializers for row indexed by 0 */
   {4, 5, 6, 7} ,   /*  initializers for row indexed by 1 */
   {8, 9, 10, 11}   /*  initializers for row indexed by 2 */
};

Example 2: matrix c declaration

int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17};

Example 3: declaring 3d arrays

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}}}

Tags:

C Example