
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
What is a multi-dimensional array in C language?
An array is a group of related items that store with a common name.
Syntax
The syntax for declaring an array is as follows −
datatype array_name [size];
Types of arrays
Arrays are broadly classified into three types. They are as follows −
- One – dimensional arrays
- Two – dimensional arrays
- Multi – dimensional arrays
Initialization
An array can be initialized in two ways. They are mentioned below −
- Compile time initialization.
- Runtime initialization.
Multi-dimensional array
- ‘C’ allows arrays of 3 (or) more dimensions.
- The exact limit is determined by compiler.
Syntax
The syntax is as follows −
datatype arrayname [size1] [size2] ----- [sizen];
For example,
- For 3 – dimensional array −
- int a[3] [3] [3];
No. of elements = 3*3*3 = 27 elements
Program
Following is the C program for multi-dimensional array −
#include<stdio.h> main ( ){ int a[2][2] [2] = {1,2,3,4,5,6,7,8}; int i,j,k; printf ("elements of the array are"); for ( i=0; i<2; i++){ for (j=0;j<2; j++){ for (k=0;k<2; k++){ printf("%d", a[i] [j] [k]); } } } }
Output
The output is stated below −
Elements of the array are : 1 2 3 4 5 6 7 8
Consider another program for Multi-Dimensional Array in C programming language, as given below −
Example
#include<stdio.h> int main(){ int tab, row, col; int students[3][3][2] = { { {1, 2}, {4, 5}},{ {2, 4}, {3, 5} },{ {7,8},{9,3}}}; for (tab = 0; tab < 3; tab++){ for (row = 0; row < 3; row++){ for (col =0; col < 2; col++){ printf("students[%d][%d][%d]= %d
", tab, row, col, students[tab][row][col]); } } } return 0; }
Output
The output is stated below −
students[0][0][0]= 1 students[0][0][1]= 2 students[0][1][0]= 4 students[0][1][1]= 5 students[0][2][0]= 0 students[0][2][1]= 0 students[1][0][0]= 2 students[1][0][1]= 4 students[1][1][0]= 3 students[1][1][1]= 5 students[1][2][0]= 0 students[1][2][1]= 0 students[2][0][0]= 7 students[2][0][1]= 8 students[2][1][0]= 9 students[2][1][1]= 3 students[2][2][0]= 0 students[2][2][1]= 0
- Related Articles
- What is a one-dimensional array in C language?
- What is a two-dimensional array in C language?
- What is the simplest multi-dimensional array in C#?
- Multi-Dimensional Array in Javascript
- Reduce a multi-dimensional array in Numpy
- What are the differences between a multi-dimensional array and jagged array?
- Greatest element in a Multi-Dimensional Array in JavaScript
- How to access elements from multi-dimensional array in C#?
- Explain pointers and two-dimensional array in C language
- Explain pointers and one-dimensional array in C language
- Converting multi-dimensional array to string in JavaScript
- Reduce a multi-dimensional array along given axis in Numpy
- Reduce a multi-dimensional array along axis 1 in Numpy
- Reduce a multi-dimensional array along negative axis in Numpy
- Reduce a multi-dimensional array and multiply elements in Numpy

Advertisements