Skip to content

Commit 7d89e15

Browse files
committed
Create 2darray.cpp
1 parent 41329f5 commit 7d89e15

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/********************
2+
* An Implementation of 2d Array using double pointer
3+
*
4+
*
5+
*
6+
*
7+
*
8+
* ************************/
9+
#include<iostream>
10+
11+
using namespace std;
12+
13+
int main() {
14+
int **arr2d;
15+
int r = 3, c = 5;
16+
17+
arr2d = new int*[r];
18+
19+
for(int i=0; i<r; i++)
20+
{
21+
int *tempPtr = new int[c];
22+
cout<<"\nEnter "<<c<<" numbers:-\n";
23+
for(int j=0; j<c; j++)
24+
cin>>*(tempPtr + j);
25+
26+
*(arr2d + i) = tempPtr;
27+
}
28+
29+
cout<<"\nContents of "<<r<<'x'<<c<<" 2d array are:-\n";
30+
for(int i=0; i<r; i++) {
31+
for(int j=0; j<c; j++)
32+
cout<<*(*(arr2d+i) + j)<<" ";
33+
cout<<"\n";
34+
}
35+
return 0;
36+
}

0 commit comments

Comments
 (0)