C- Memory Allocation Questions and Answers

Take Exam

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)
Show Answer Report

22. Which function can change the size of allocated memory block?

  • realloc()
  • malloc()
  • calloc()
  • free()
Show Answer Report

23. What does "stack overflow" refer to?

  • Exhaustion of stack memory
  • Heap memory full
  • Too many malloc calls
  • Memory fragmentation
Show Answer Report

24. What is memory fragmentation?

  • Non-contiguous free memory blocks
  • Memory with errors
  • Memory allocated too slowly
  • Memory not initialized
Show Answer Report

25. Which is faster: malloc() or calloc()?

  • malloc()
  • calloc()
  • Both are same speed
  • Depends on system
Show Answer Report

26. What is wild pointer?

  • Uninitialized pointer
  • Pointer to freed memory
  • Constant pointer
  • Pointer to stack
Show Answer Report

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
Show Answer Report

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
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test