Here, we'll learn the delete keyword that's used to clear the dynamically allocated memory in CPP.
Given a dynamic array A of size N. The task is to find the sum of array elements.
First line of input contains number of testcases T. For each testcase, there will two line of input, first of which contains N, size of array. Next line contains N integers.
For each testcase, output the sum of array elements and in next line prints the first array element(A).
Just comment the line that is deallocating the array.
1 <= T <= 10
1 <= N <= 100
1 <= A[i] <= 105
1 2 3 4 5
Testcase 1: Sum of array elements is 15 (1 + 2 + 3 + 4 + 5). The first element is 1.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.