forked from purushottamnawale/geeksforgeeks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete Array.cpp
More file actions
47 lines (32 loc) · 830 Bytes
/
Delete Array.cpp
File metadata and controls
47 lines (32 loc) · 830 Bytes
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
39
40
41
42
43
44
45
46
47
//{ Driver Code Starts
//Initial Template for C++
#include <iostream>
using namespace std;
int main() {
int testcase;
cin >> testcase;
while(testcase--){
int N;
cin >> N;
// Declaring dynamic 1D array
int *arr = new int[N];
for(int i = 0;i<N;i++){
cin >> arr[i];
}
int sum = 0;
for(int i = 0;i<N;i++){
sum += arr[i];
}
// } Driver Code Ends
//User function Template for C++
// Code to delete the array
// Task is to comment the line which deletes
// the array such that required output is printed
// delete[] arr; //comment this line so memory doesn't get deallocated
//{ Driver Code Starts.
cout << sum << endl;
cout << arr[0] << endl;
}
return 0;
}
// } Driver Code Ends