forked from Ayush-chhabra/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP2.cpp
More file actions
52 lines (43 loc) · 807 Bytes
/
P2.cpp
File metadata and controls
52 lines (43 loc) · 807 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
using namespace std;
class twoD
{
private:
int m,n;
public:
void Output(int arr[20][20]);
void Input(int arr[20][20]);
};
void twoD::Input(int arr[20][20])
{
cout<<"Enter no. of Rows: ";
cin>>m;
cout<<"Enter no. of Columns: ";
cin>>n;
cout<<"Enter elements of the Array: "<<endl;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>*(*(arr+i)+j);
}
}
}
void twoD::Output(int arr[20][20])
{
cout<<endl;
for(int i=0;i<m;i++)
{ cout<<endl;
for(int j=0;j<n;j++)
cout<<*(*(arr+i)+j);
}
}
int main()
{
int arr[20][20];
cout<<endl<<"For 2D Array"<<endl;
twoD obj;
obj.Input(arr);
obj.Output(arr);
return 0;
}