250+ TOP MCQs on Storage Management and Answers

C problems on “Storage Management”. One shall practice these problems to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These problems can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C problems come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C problems on “Storage Management” along with answers, explanations and/or solutions:

1. The function ____ obtains a block of memory dynamically.
a) calloc
b) malloc
c) both calloc & malloc
d) free
Answer: c
Clarification: 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
Answer: a
Clarification: None.

3. calloc() returns storage that is initialized to.
a) Zero
b) Null
c) Nothing
d) One
Answer: a
Clarification: 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()
Answer: d
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         char *p = calloc(100, 1);
  5.         p = "welcome";
  6.         printf("%sn", p);
  7.     }

a) Segmentation fault
b) Garbage
c) Error
d) welcome
Answer: d
Clarification: None.

6. Memory allocation using malloc() is done in _________
a) Static area
b) Stack area
c) Heap area
d) Both Stack & Heap area
Answer: c
Clarification: 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
Answer: b
Clarification: 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);
Answer: c
Clarification: None.

contest

Leave a Reply

Your email address will not be published. Required fields are marked *