Skip to content

Commit 4c8154f

Browse files
Dyanmic Array Practice Problem-1 Solved
1 parent af5060e commit 4c8154f

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

dynamic_array_problem1.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int *get_array(int n)
5+
{
6+
int *p = new int[n];
7+
for (int i = 0; i < n; i++)
8+
{
9+
cin >> p[i];
10+
}
11+
return p;
12+
}
13+
14+
int main()
15+
{
16+
int n;
17+
cin >> n;
18+
int *ar = get_array(n);
19+
for (int i = 0; i < n; i++)
20+
{
21+
cout << ar[i] << " ";
22+
}
23+
24+
return 0;
25+
}

dynamic_array_problem1.exe

50.2 KB
Binary file not shown.

output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
50 40 30 20 10
1+
30 50 10 20 40

0 commit comments

Comments
 (0)