C/C++ Arena

Step 2 of 9

Size decided at runtime

The real power of malloc: the size can come from input.

Your turn: read n, then n numbers into a heap array. Print how many are above the average. Free the array at the end.

Input 4 / 2 4 6 8 (average 5) prints 2.

Previous: Stack vs heap Next: Return heap memory from a function