SlideShare a Scribd company logo
3
Most read
5
Most read
7
Most read
Multi-dimensional Array
Md. Imran Hossain Showrov (showrovsworld@gmail.com)
16
1
Outline
 Multidimensional Array
Multi-dimensional Array
 C programming language allows multidimensional
arrays. Here is the general form of a multidimensional
array declaration −
type name[size1][size2] ……. [sizeN];
 For example, the following declaration creates a three
dimensional integer array −
int threedim[5][10][4];
Multi-dimensional Array (cont..)
 Three Dimensional Array
Multi-dimensional Array (cont..)
 Easy way to remember Three Dimensional Array
Array[Row][Column][NumberOfElements]
Here,
Row = number of rows
Column = number of columns
NumberOfElements = number of elements in each row
and column
Multi-dimensional Array (cont..)
 Initialization of a three dimensional array.
Method 1:
int x[2][3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23};
Better Method:
int x[2][3][4] =
{
{ {0,1,2,3}, {4,5,6,7}, {8,9,10,11} },
{ {12,13,14,15}, {16,17,18,19}, {20,21,22,23} }
};
Multi-dimensional Array (cont..)
// C++ program to print elements of Three-Dimensional
int x[2][3][2] =
{ { {0,1}, {2,3}, {4,5} },
{ {6,7}, {8,9}, {10,11} } };
printf("nDisplaying values:n");
for(i = 0; i < 2; ++i) {
for (j = 0; j < 3; ++j) {
for(k = 0; k < 2; ++k ) {
printf("test[%d][%d][%d] = %dn", i, j, k, test[i][j][k]);
}
}
}
Multi-dimensional Array (cont..)
Output:
DisplayingValues:
test[0][0][0] = 1 test[1][0][0] = 7
test[0][0][1] = 2 test[1][0][1] = 8
test[0][1][0] = 3 test[1][1][0] = 9
test[0][1][1] = 4 test[1][1][1] = 10
test[0][2][0] = 5 test[1][2][0] = 11
test[0][2][1] = 6 test[1][2][1] = 12
Multi-dimensional Array (Example 2)
int t[10][20][30] = {
{ /* table 1 */
{1, 2, 3, 4}, /* row 1 */
{5, 6, 7, 8}, /* row 2 */
{9, 10, 11, 12}, /* row 3 */
},
{ /* table 2 */
{21, 22, 23, 24}, /* row 1 */
{25, 26, 27, 28}, /* row 2 */
{29, 30, 31, 32}, /* row 3 */
},
}
Lecture 16 - Multi dimensional Array

More Related Content

PPT
One Dimensional Array
PPTX
concept of Array, 1D & 2D array
PPT
Chapter 14 - Protection
PPTX
View of data DBMS
PPTX
2D Array
PPT
data structure
PPTX
HTML: Tables and Forms
One Dimensional Array
concept of Array, 1D & 2D array
Chapter 14 - Protection
View of data DBMS
2D Array
data structure
HTML: Tables and Forms

What's hot (20)

PPTX
Database Connectivity in PHP
PPTX
Multistage graph unit 4 of algorithm.ppt
PDF
Python Dictionary
PPTX
This keyword in java
PPTX
Java - Generic programming
PPT
Applet life cycle
PPT
Problem Solving Aspect of Swapping Two Integers using a Temporary Variable
PPTX
Type casting in java
PPTX
Unit I - Evaluation of expression
PPT
Data Structures- Part5 recursion
PPTX
6.applet programming in java
PPTX
sorting and its types
PPTX
Java exception handling
PPTX
Html form
PPTX
Array Introduction One-dimensional array Multidimensional array
PPT
Abstract data types
PPT
PDF
Java - File Input Output Concepts
PPTX
Complexity analysis in Algorithms
PPTX
Collision in Hashing.pptx
Database Connectivity in PHP
Multistage graph unit 4 of algorithm.ppt
Python Dictionary
This keyword in java
Java - Generic programming
Applet life cycle
Problem Solving Aspect of Swapping Two Integers using a Temporary Variable
Type casting in java
Unit I - Evaluation of expression
Data Structures- Part5 recursion
6.applet programming in java
sorting and its types
Java exception handling
Html form
Array Introduction One-dimensional array Multidimensional array
Abstract data types
Java - File Input Output Concepts
Complexity analysis in Algorithms
Collision in Hashing.pptx
Ad

Similar to Lecture 16 - Multi dimensional Array (20)

PPTX
Arrays in C language
PPTX
Array in c programming
PPTX
Programming in c arrays
PPT
07 Arrays
PPTX
PPT
Multi dimensional arrays
PPT
arrays used for data structures and algorithms
PPTX
Array ppt you can learn in very few slides.
PPTX
PDF
ARRAYS
PPTX
Array.pptx Array.pptxArray.pptx Array.pptxArray.pptxArray.pptx
PPTX
PPTX
Visual Programing basic lectures 7.pptx
PPTX
Abir ppt3
PPTX
ARRAYSCPP.pptx
DOC
Arrays In General
PDF
Array in C.pdf
PDF
Array.pdf
PPTX
Programming in c Arrays
Arrays in C language
Array in c programming
Programming in c arrays
07 Arrays
Multi dimensional arrays
arrays used for data structures and algorithms
Array ppt you can learn in very few slides.
ARRAYS
Array.pptx Array.pptxArray.pptx Array.pptxArray.pptxArray.pptx
Visual Programing basic lectures 7.pptx
Abir ppt3
ARRAYSCPP.pptx
Arrays In General
Array in C.pdf
Array.pdf
Programming in c Arrays
Ad

More from Md. Imran Hossain Showrov (20)

PPT
Lecture 22 - Error Handling
PPT
Lecture 21 - Preprocessor and Header File
PPT
Lecture 20 - File Handling
PPT
Lecture 19 - Struct and Union
PPT
Lecture 18 - Pointers
PPT
Lecture 17 - Strings
PPT
Lecture 15 - Array
PPT
Lecture 14 - Scope Rules
PPT
Lecture 13 - Storage Classes
PPT
Lecture 12 - Recursion
PPT
Lecture 11 - Functions
PPT
Lecture 10 - Control Structures 2
PPT
Lecture 8- Data Input and Output
PPT
Lecture 9- Control Structures 1
PPT
Lecture 7- Operators and Expressions
PPT
Lecture 6- Intorduction to C Programming
PPT
Lecture 5 - Structured Programming Language
PPT
Lecture 4- Computer Software and Languages
PPT
Lecture 3 - Processors, Memory and I/O devices
PPT
Lecture 2 - Introductory Concepts
Lecture 22 - Error Handling
Lecture 21 - Preprocessor and Header File
Lecture 20 - File Handling
Lecture 19 - Struct and Union
Lecture 18 - Pointers
Lecture 17 - Strings
Lecture 15 - Array
Lecture 14 - Scope Rules
Lecture 13 - Storage Classes
Lecture 12 - Recursion
Lecture 11 - Functions
Lecture 10 - Control Structures 2
Lecture 8- Data Input and Output
Lecture 9- Control Structures 1
Lecture 7- Operators and Expressions
Lecture 6- Intorduction to C Programming
Lecture 5 - Structured Programming Language
Lecture 4- Computer Software and Languages
Lecture 3 - Processors, Memory and I/O devices
Lecture 2 - Introductory Concepts

Recently uploaded (20)

PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PDF
English Language Teaching from Post-.pdf
PDF
Business Ethics Teaching Materials for college
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Cell Structure & Organelles in detailed.
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
NOI Hackathon - Summer Edition - GreenThumber.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides
Cardiovascular Pharmacology for pharmacy students.pptx
human mycosis Human fungal infections are called human mycosis..pptx
The Final Stretch: How to Release a Game and Not Die in the Process.
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
English Language Teaching from Post-.pdf
Business Ethics Teaching Materials for college
STATICS OF THE RIGID BODIES Hibbelers.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
UPPER GASTRO INTESTINAL DISORDER.docx
O7-L3 Supply Chain Operations - ICLT Program
Renaissance Architecture: A Journey from Faith to Humanism
Cell Structure & Organelles in detailed.
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Anesthesia in Laparoscopic Surgery in India
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Pharma ospi slides which help in ospi learning
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)

Lecture 16 - Multi dimensional Array

  • 3. Multi-dimensional Array  C programming language allows multidimensional arrays. Here is the general form of a multidimensional array declaration − type name[size1][size2] ……. [sizeN];  For example, the following declaration creates a three dimensional integer array − int threedim[5][10][4];
  • 4. Multi-dimensional Array (cont..)  Three Dimensional Array
  • 5. Multi-dimensional Array (cont..)  Easy way to remember Three Dimensional Array Array[Row][Column][NumberOfElements] Here, Row = number of rows Column = number of columns NumberOfElements = number of elements in each row and column
  • 6. Multi-dimensional Array (cont..)  Initialization of a three dimensional array. Method 1: int x[2][3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}; Better Method: int x[2][3][4] = { { {0,1,2,3}, {4,5,6,7}, {8,9,10,11} }, { {12,13,14,15}, {16,17,18,19}, {20,21,22,23} } };
  • 7. Multi-dimensional Array (cont..) // C++ program to print elements of Three-Dimensional int x[2][3][2] = { { {0,1}, {2,3}, {4,5} }, { {6,7}, {8,9}, {10,11} } }; printf("nDisplaying values:n"); for(i = 0; i < 2; ++i) { for (j = 0; j < 3; ++j) { for(k = 0; k < 2; ++k ) { printf("test[%d][%d][%d] = %dn", i, j, k, test[i][j][k]); } } }
  • 8. Multi-dimensional Array (cont..) Output: DisplayingValues: test[0][0][0] = 1 test[1][0][0] = 7 test[0][0][1] = 2 test[1][0][1] = 8 test[0][1][0] = 3 test[1][1][0] = 9 test[0][1][1] = 4 test[1][1][1] = 10 test[0][2][0] = 5 test[1][2][0] = 11 test[0][2][1] = 6 test[1][2][1] = 12
  • 9. Multi-dimensional Array (Example 2) int t[10][20][30] = { { /* table 1 */ {1, 2, 3, 4}, /* row 1 */ {5, 6, 7, 8}, /* row 2 */ {9, 10, 11, 12}, /* row 3 */ }, { /* table 2 */ {21, 22, 23, 24}, /* row 1 */ {25, 26, 27, 28}, /* row 2 */ {29, 30, 31, 32}, /* row 3 */ }, }