CJCoding With Joseph
15free / daySign inCreate account

Heap Array of Readings with unique_ptr<int[]>

Read 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 — print one after the last line.

Hints4 available
Topics:
Pointers
📥 Auto-Input:
5\n4 9 2 7 3\n
This input is automatically fed to your program's stdin
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.