CJCoding With Joseph
15free / daySign inCreate account

Read an integer n from input, then read n more integers. Allocate an int array of exactly n elements with malloc, store the values in it, and then print:

- each stored value MULTIPLIED BY 2, one per line, in the order they were read - a final line "Sum: <s>" where <s> is the sum of the ORIGINAL (not doubled) values

For the input:

4 5 1 9 3

the output is exactly what is shown in Expected Output.

Free the memory you allocate before the program ends — this question checks for memory leaks.

Expected output

10
2
18
6
Sum: 18

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
Pointers
Auto-input
4\n5 1 9 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 (p, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.