- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMulti_Dimensional_array.cpp
More file actions
Latest commit
37 lines (36 loc) · 757 Bytes
/
Copy pathMulti_Dimensional_array.cpp
File metadata and controls
37 lines (36 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Create an multidimensional array and initialize with values and display in row and coloumn major order.
#include<iostream>
usingnamespacestd;
intmain()
{
int arr[2][3][3]={{{1,2,3},{4,5,6},{7,8,9}},
{{10,11,12},{13,14,15},{16,17,18}}};
int i,j,k;
cout<<"Row wise\n";
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
cout<<"["<<i<<"]"<<"["<<j<<"]"<<"["<<k<<"]"<<"="<<arr[i][j][k];
}
cout<<"\n";
}
cout<<"\n";
}
cout<<"Coloumn wise\n";
for(i=0;i<2;i++)
{
for(k=0;k<3;k++)
{
for(j=0;j<3;j++)
{
cout<<"["<<i<<"]"<<"["<<j<<"]"<<"["<<k<<"]"<<"="<<arr[i][j][k];
}
cout<<"\n";
}
cout<<"\n";
}
return0;
}