Memory Allocation on C related Questions and Answers

Question 1 : When the pointer is NULL, then the function realloc is equivalent to the function ___________
1. malloc
2. calloc
3. free
4. alloc
View Answer   Discuss with Members

Question 2 : Suppose we have a one dimensional array, named 'x', which contains 10 integers. Which of the following is the correct way to allocate memory dynamically to the array 'x' using malloc()?
1. x=(int*)malloc(10);
2. x=(int*)malloc(10,sizeof(int));
3. x=malloc(int 10,sizeof(int));
4. x=(int*)malloc(10*sizeof(int));
View Answer   Discuss with Members

Question 3 : If the space in memory allocated by malloc is not sufficient, then an allocation fails and returns ___________
1. NULL pointer
2. Zero
3. Garbage value
4. The number of bytes available
View Answer   Discuss with Members

Question 4 : If malloc() and calloc() are not type casted, the default return type is ___________
1. void*
2. void**
3. int*
4. char*
View Answer   Discuss with Members

Question 5 : In the function malloc(), each byte of allocated space is initialized to zero.
1. True
2. False
3.
4.
View Answer   Discuss with Members

Question 6 : Which of the following functions allocates multiple blocks of memory, each block of the same size?
1. malloc()
2. realloc()
3. calloc()
4. free()
View Answer   Discuss with Members

Question 7 : In the function realloc(), if the new size of the memory block is larger than the old size, then the added memory ___________
1. is initialized to junk values
2. is initialized to zero
3. results in an error
4. is not initialized
View Answer   Discuss with Members

Question 8 : If malloc() and calloc() are not type casted, the default return type is ___________
1. void*
2. void**
3. int*
4. char*
View Answer   Discuss with Members

Question 9 : If the space in memory allocated by malloc is not sufficient, then an allocation fails and returns ___________
1. NULL pointer
2. Zero
3. Garbage value
4. The number of bytes available
View Answer   Discuss with Members

Question 10 : Which of the following is an example for static memory allocation?
1. Linked list
2. Stack
3. Queue
4. Array
View Answer   Discuss with Members


View 1 - 10 of 33 Questions

* Be the First to Post a Comment.

Submit comment :


Captcha Image
Reload

Ask Question

Captcha Image
Reload

Note : Name and Email never shown.





Subscribe


Become a part of EducationForever. Subscribe to our FREE Newsletter