Introduction to Programming MCQs with Answers
Practice important Introduction to Programming MCQs with answers and explanations.
Multiple Choice Questions
Q411: What does the calloc function do apart from allocating memory?
- A: It initializes the memory to zero
- B: It initializes the memory to one
- C: It doesn't initialize memory
- D: It deallocates memory
View Answer
A
Q412: Which header files define the NULL macro in C?
- A: stdlib.h and stddef.h
- B: string.h and stdio.h
- C: malloc.h and memory.h
- D: math.h and conio.h
View Answer
A
Q413: What is the purpose of the free() function in dynamic memory allocation?
- A: To allocate memory dynamically
- B: To deallocate memory and return to heap
- C: To initialize memory to zero
- D: To copy memory contents
View Answer
B
Q414: How does malloc differ from calloc in memory initialization?
- A: malloc initializes memory to zero
- B: malloc initializes memory to one
- C: malloc does not initialize memory
- D: malloc initializes memory to NULL
View Answer
C
Q415: What does realloc do when it cannot extend the current memory block?
- A: Allocates a new block and copies contents
- B: Returns NULL
- C: Keeps the current block unchanged
- D: Terminates the program
View Answer
A
Q416: What should be checked after every dynamic memory allocation call?
- A: Whether the pointer is NULL
- B: Whether the memory is full
- C: Whether the stack is empty
- D: Whether the memory is contiguous
View Answer
A
Q417: Which operator is used for casting a void pointer to a specific data type in C?
- A: sizeof
- B: malloc
- C: free
- D: Standard cast operator
View Answer
D
Q418: Which programming language was primarily used for writing the Unix operating system?
- A: COBOL
- B: FORTRAN
- C: C
- D: C++
View Answer
C
Q419: What approach does C follow in structured programming?
- A: Bottom-up
- B: Top-down
- C: Object-Oriented
- D: Data-driven
View Answer
B
Q420: What was C++ initially called?
- A: C with Classes
- B: C plus plus
- C: Java
- D: Structured C
View Answer
A