malloc can reserve many ints: malloc(n * sizeof(int)). Then use p[i] like an array.
malloc can rent a whole row: three ints in one block. You use p[i] like an array, add them up, print 6, then free the block once — not once per index.
heap
fill
6
one block
Each step highlights the matching C line. Program output appears only when a line that prints actually runs.
Five questions. Pick one answer each, then Check answers. The correct choice turns green.
1. 1+2+3 prints:
Sum.
2. malloc(3 * sizeof(int)) is:
One block.
3. free(p) frees:
One free.
4. p[i] works because:
Array indexing on a pointer.
5. Stack int a[3] vs this malloc:
Lifetime and size.