-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
38 lines (32 loc) · 848 Bytes
/
test.cpp
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
#include <iostream>
using namespace std;
// function to create array with undefined memory values and n size
int *createArrayN(int n) {
int *array = new int[n];
// return array = new int[n];
return array;
}
void *modifyArray(int *array, int n) {
for (int i{}; i < n; i++) {
cout << i << "; ";
// array[i] = i;
cout << "val: "; cin >> array[i];
cout << "array val: " << array[i] << endl;
}
cout << flush;
// return array;
}
int main() {
// size as 10
int n = 10;
// call function to create the array with n size and store it
int *newArray = createArrayN(n);
for (int i{}; i < n; i++) {
cout << "Val: " << *newArray << endl;
}
modifyArray(newArray, n);
for (int i{}; i < n; i++) {
cout << newArray[i] << endl;
}
return 0;
}