Sail E0 Webinar

MCQs

Total Questions : 11 | Page 1 of 2 pages
Question 1. Memory allocation using malloc() is done in?
  1.    Static area
  2.    Stack area
  3.    Heap area
  4.    Both b & c
 Discuss Question
Answer: Option C. -> Heap area


None.


Question 2. Which one is used during memory deallocation in C?
  1.    remove(p);
  2.    delete(p);
  3.    free(p);
  4.    terminate(p);
 Discuss Question
Answer: Option C. -> free(p);


None.


Question 3. Which of the following will return a result most quickly for searching a given key?
  1.    Unsorted Array
  2.    Sorted Array
  3.    Sorted linked list
  4.    Binary Search Tree
 Discuss Question
Answer: Option D. -> Binary Search Tree


None.


Question 4. On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to?
  1.    NULL
  2.    Other dynamically allocated memory
  3.    The same deallocated memory location
  4.    It points back to location it was initialized with
 Discuss Question
Answer: Option C. -> The same deallocated memory location


None.


Question 5. Why do we write (int *) before malloc?    
int *ip = (int *)malloc(sizeof(int));
  1.    It is for the syntax correctness
  2.    It is for the type-casting
  3.    It is to inform malloc function about the data-type expected
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> It is for the type-casting


None.


Question 6. The function ____ obtains block of memory dynamically.
  1.    calloc
  2.    malloc
  3.    Both a & b
  4.    free
 Discuss Question
Answer: Option C. -> Both a & b


None.


Question 7. In function free(p), p is a:
  1.    int
  2.    Pointer returned by malloc()
  3.    Pointer returned by calloc()
  4.    Both b & c
 Discuss Question
Answer: Option D. -> Both b & c


None.


Question 8. calloc() returns a storage that is initialized to.
  1.    Zero
  2.    Null
  3.    Nothing
  4.    One
 Discuss Question
Answer: Option A. -> Zero


None.


Question 9. What is the output of this C code?
void main()
{
char *p = calloc(100, 1);
p = "welcome";
printf("%s\n", p);
}
  1.    Segmentation fault
  2.    garbage
  3.    Error
  4.    welcome
 Discuss Question
Answer: Option D. -> welcome


None.


Question 10. void * malloc(size_t n) returns:
  1.    Pointer to n bytes of uninitialized storage
  2.    NULL if the request cannot be satisfied
  3.    Nothing
  4.    Both a & b are true
 Discuss Question
Answer: Option D. -> Both a & b are true


None.


Latest Videos

Latest Test Papers