Multi dimensional Array in C

Preview
You must first complete for statement in c language | Nesting of for in c language before viewing this Lesson

Multi dimensional Arrays

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

Syntax :

<Type> Array_name[size1][size2][size3]……………….;

size1,size2,size3,…. specify the dimensions in the multidimensional array. They should be integer values.


Program 
#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 Computer Science









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