C- Memory Allocation Questions and Answers
Practice ModeShowing 10 of 28 questions
Q21
What is the syntax for allocating memory for 10 integers using malloc()?
Answer: Option A
Explanation: malloc(10 * sizeof(int)) allocates memory for 10 integers.
Q22
Which function can change the size of allocated memory block?
Answer: Option A
Explanation: realloc() can resize previously allocated memory block.
Q23
What does "stack overflow" refer to?
Answer: Option A
Explanation: Stack overflow occurs when stack memory is exhausted due to deep recursion or large local variables.
Q24
What is memory fragmentation?
Answer: Option A
Explanation: Memory fragmentation occurs when free memory is divided into small, non-contiguous blocks.
Q25
Which is faster: malloc() or calloc()?
Answer: Option A
Explanation: malloc() is generally faster as it doesn't initialize memory to zero.
Q26
What is wild pointer?
Answer: Option A
Explanation: Wild pointer is uninitialized pointer that points to random memory location.
Q27
How to avoid memory leaks in C?
Answer: Option A
Explanation: Always free allocated memory and set pointer to NULL after freeing.
Q28
What is the purpose of the sizeof operator in malloc()?
Answer: Option A
Explanation: sizeof calculates the size in bytes needed for each element.