Home Subjects C Programming Dynamic Memory

C Programming
Dynamic Memory

C language from basics to advanced placement prep

25 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–25 of 25
Topics in C Programming
Q.21 Easy Dynamic Memory
Which header file must be included to use malloc(), calloc(), and free() functions?
A #include
B #include
C #include
D #include
Correct Answer:  B. #include
EXPLANATION

All memory allocation and deallocation functions are declared in <stdlib.h>.

Test
Q.22 Easy Dynamic Memory
How much memory is allocated by malloc(sizeof(int) * 10) on a 32-bit system where sizeof(int) = 4?
A 10 bytes
B 40 bytes
C 4 bytes
D 44 bytes
Correct Answer:  B. 40 bytes
EXPLANATION

sizeof(int) * 10 = 4 * 10 = 40 bytes on a 32-bit system.

Test
Q.23 Easy Dynamic Memory
Which function is used to free dynamically allocated memory?
A delete()
B release()
C free()
D unalloc()
Correct Answer:  C. free()
EXPLANATION

free() is the standard function to deallocate memory previously allocated by malloc(), calloc(), or realloc().

Test
Q.24 Easy Dynamic Memory
What does calloc() do differently from malloc()?
A Allocates more memory
B Initializes memory to zero
C Allocates memory faster
D Returns integer instead of void pointer
Correct Answer:  B. Initializes memory to zero
EXPLANATION

calloc() takes two arguments (number of elements and size) and initializes all allocated bytes to zero, unlike malloc().

Test
Q.25 Easy Dynamic Memory
Which header file is required for dynamic memory allocation functions?
A
B
C
D
Correct Answer:  B.
EXPLANATION

The <stdlib.h> header file contains declarations for malloc(), calloc(), realloc(), and free() functions.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips