Multi dimensional Array in C

Preview
You must first complete Two dimensional array in C | Initialization of Two dimensional array in C before viewing this Lesson

Multi dimensional Arrays

An array containing more than two dimensions is called multi-dimensional array. We can use more than two pairs of brackets to specify the size or refer any array element

Syntax :

<Data_Type> Array_name[s1][s2][s3]……………….;

s1,s2,s3,…. specify the dimensions in the multidimensional array. They should be integer values.


Program of  multi dimensional array.
#include<stdio.h>
int main()
{
int a[2][2][2]={1,2,3,4,5,6,7,8};

printf(“\n%d”,a[0][0][0]);
printf(“\n%d”,a[0][0][1]);
printf(“\n%d”,a[0][1][0]);
printf(“\n%d”,a[0][1][1]);

 

printf(“\n%d”,a[1][0][0]);
printf(“\n%d”,a[1][0][1]);
printf(“\n%d”,a[1][1][0]);
printf(“\n%d”,a[1][1][1]);
return(0);
}

Best Books of C





Lesson tags: multidimensional array in c, program of multi dimensional array in c
Back to: C Programming Language