Skip to content

Commit 08493bc

Browse files
Creating and printing a basic dynamic array
1 parent 9df5296 commit 08493bc

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

dynamic_array.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
// int a[5] = {10, 20, 30, 40, 50};
7+
// cout << a[1];
8+
int n;
9+
cin >> n;
10+
int *a = new int[n];
11+
for (int i = 0; i < n; i++)
12+
{
13+
cin >> a[i];
14+
}
15+
16+
for (int i = 0; i < n; i++)
17+
{
18+
cout << a[i] << " ";
19+
}
20+
21+
return 0;
22+
}

dynamic_array.exe

50.1 KB
Binary file not shown.

input.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
5
2+
10 20 30 40 50

output.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
10
2-
20.50
3-
Address of a: 0x61fed8
4-
0x10d9018
1+
10 20 30 40 50

0 commit comments

Comments
 (0)