Heap Array of Readings with unique_ptr<int[]>
mediumQuestion 706Read an integer n (always at least 1) followed by n integers. Store the values in a unique_ptr<int[]> of exactly size n, built with std::make_unique<int[]>(n), then print the count, their sum, and the largest of them. The values may be negative.
For the input: 5 4 9 2 7 3
the program prints exactly the output shown in Expected Output.
Do not write delete[] and do not use a raw new — this question checks for memory leaks.
Expected output
Count: 5 Sum: 25 Max: 9
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.