Area of Improvements
Review your assessments and practice — drill into each subject, then each attempt, then each question.
Back to summary
C Programming · Round 1
Question 5 of 10
Topic: Type castingDifficulty: HardBloom: Apply
Question
Design a small program that uses dynamic memory allocation as a core building block.
Result
Knowledge
60%
Delivery
72%
Technical relevancy
65%
Technical term match
55%
Your recording
Your transcript
I'd write a program that reads numbers and stores them in an array using malloc. If it gets full I realloc to double the size. At the end I free the memory.
Better answer
A growable int vector: struct with data pointer, length, capacity. push() reallocs to 2x capacity when full (amortised O(1)). Always check malloc/realloc return for NULL, free on shutdown, and zero the pointer after free to avoid double-free. Document ownership: who allocates, who frees.
Coverage
Hit 2 of 5- Uses malloc and realloc with doubling strategy
- Calls free at the end
- Checks malloc/realloc return for NULL
- Discusses ownership / who frees
- Mentions amortised O(1) push
Gaps
- Did not handle allocation failure
- No mention of zeroing pointer after free
Misconceptions
- Implied realloc never moves the buffer

