MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/pointers_dynamicMemory/2d-Dynamic.cpp:9–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#define endl '\n'
8
9int main(){
10 cin.tie(0)->sync_with_stdio(0);
11 int n,m;
12 cin>>n>>m;
13
14 // creation of 2array
15 //
16 int **arr= new int *[n];
17 for (int i = 0; i < n; i++) {
18 arr[i]= new int[n];
19
20 }
21 // taking input
22 for (int i = 0; i < n; i++) {
23 for (int j = 0; j < m; j++) {
24 cin>>arr[i][j];
25 }
26 }
27 // giving the outputl
28 for (int i = 0; i < n; i++) {
29 for (int j = 0; j < m; j++) {
30 cout<<arr[i][j]<<" ";
31 }
32 cout<<endl;
33 }
34 //releasing of all the heap memory
35 for (int i = 0; i < n; i++) {
36 delete [] arr[i];
37
38 }
39 delete []arr;
40 return 0;
41}
42
43

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected