This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Storage Management – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. The function ____ obtains a block of memory dynamically.
a) calloc
b) malloc
c) both calloc & malloc
d) free
View Answer
Explanation: None.
2. void * malloc(size_t n) returns?
a) Pointer to n bytes of uninitialized storage
b) NULL if the request can be satisfied
c) Nothing
d) None of the mentioned
View Answer
Explanation: None.
3. calloc() returns storage that is initialized to.
a) Zero
b) Null
c) Nothing
d) One
View Answer
Explanation: None.
4. In function free(p), p is a _______
a) int
b) pointer returned by malloc()
c) pointer returned by calloc()
d) pointer returned by malloc() & calloc()
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *p = calloc(100, 1);
p = "welcome";
printf("%s\n", p);
}
a) Segmentation fault
b) Garbage
c) Error
d) welcome
View Answer
Explanation: None.
6. Memory allocation using malloc() is done in _________
a) Static area
b) Stack area
c) Heap area
d) Both Stack & Heap area
View Answer
Explanation: None.
7. Why do we write (int *) before malloc?
int *ip = (int *)malloc(sizeof(int));
a) It is for the syntax correctness
b) It is for the type-casting
c) It is to inform malloc function about the data-type expected
d) None of the mentioned
View Answer
Explanation: None.
8. Which of the following is used during memory deallocation in C?
a) remove(p);
b) delete(p);
c) free(p);
d) terminate(p);
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Computer Science Books
- Apply for C Internship
- Buy C Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs