C- Memory Allocation Questions and Answers
C Memory Allocation questions with answers are vital for mastering dynamic memory management in C programming. These programming questions and answers help learners understand malloc(), calloc(), realloc(), and free() functions in detail. Practicing C programming MCQ or programming interview questions with answers builds a strong foundation for coding interviews and placement exams at companies like TCS, Infosys, and Accenture. Proper memory allocation ensures efficient use of system resources and prevents memory leaks, which are common pitfalls for beginners. Through regular practice, students can develop confidence in handling memory dynamically during programming test practice sessions or while preparing for technical rounds.
C- Memory Allocation
Showing 10 of
28 questions
21. What is the syntax for allocating memory for 10 integers using malloc()?
- malloc(10 * sizeof(int))
- malloc(10, int)
- malloc(sizeof(int) * 10)
- alloc(10 * int)
22. Which function can change the size of allocated memory block?
- realloc()
- malloc()
- calloc()
- free()
23. What does "stack overflow" refer to?
- Exhaustion of stack memory
- Heap memory full
- Too many malloc calls
- Memory fragmentation
24. What is memory fragmentation?
- Non-contiguous free memory blocks
- Memory with errors
- Memory allocated too slowly
- Memory not initialized
25. Which is faster: malloc() or calloc()?
- malloc()
- calloc()
- Both are same speed
- Depends on system
26. What is wild pointer?
- Uninitialized pointer
- Pointer to freed memory
- Constant pointer
- Pointer to stack
27. How to avoid memory leaks in C?
- Free memory and set pointer to NULL
- Use only stack memory
- Avoid using pointers
- Use automatic garbage collection
28. What is the purpose of the sizeof operator in malloc()?
- Calculate element size in bytes
- Count number of elements
- Check memory alignment
- Verify pointer validity