← Back to Pointers
Question 706
Heap Array of Readings with unique_ptr<int[]>
Heap Array of Readings with unique_ptr<int[]>
Read an integern(always at least 1) followed bynintegers. Store the values in aunique_ptr<int[]>of exactly sizen, built withstd::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 writedelete[]and do not use a rawnew— this question checks for memory leaks.
Expected Output:
Count: 5 Sum: 25 Max: 9
= newline. The output ends with a newline — 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.