-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_array_9.cpp
56 lines (51 loc) · 1.19 KB
/
func_array_9.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// passing 3d array to function
#include <iostream>
using namespace std;
int input(int[][3][3], int);
void display(int[][3][3], int);
int main()
{
int p;
cout << "Enter the number of pages of the array: ";
cin >> p;
int arr[p][3][3];
cout << "Enter the elements in 2-D array: " << endl;
input(arr, p);
cout << "Display the elements of 2-D array: " << endl;
display(arr, p);
return 0;
}
int input(int arr[][3][3], int p)
{
for (int i = 0; i < p; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 3; k++)
{
cout << "arr[" << i << "][" << j << "][" << k << "] = ";
cin >> arr[i][j][k];
}
}
cout << endl;
}
return arr[p][3][3];
}
void display(int arr[][3][3], int p)
{
for (int i = 0; i < p; i++)
{
cout << "|";
for (int j = 0; j < 3; j++)
{
cout << "|";
for (int k = 0; k < 3; k++)
{
cout << arr[i][j][k] << " ";
}
cout << "|";
cout << endl;
}
cout << endl;
}
}