Home / CSE MCQs / C-MCQs :: Storage Management

CSE MCQs :: C-MCQs

  1. The function ____ obtains block of memory dynamically.
  2. A.
    calloc
    B.
    malloc
    C.
    Both a & b
    D.
    free

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. void * malloc(size_t n) returns:
  4. A.
    Pointer to n bytes of uninitialized storage
    B.
    NULL if the request cannot be satisfied
    C.
    Nothing
    D.
    Both a & b are true

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. calloc() returns a storage that is initialized to.
  6. A.
    Zero
    B.
    Null
    C.
    Nothing
    D.
    One

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. In function free(p), p is a:
  8. A.
    int
    B.
    Pointer returned by malloc()
    C.
    Pointer returned by calloc()
    D.
    Both b & c

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of this C code?

    void main()
    {
    char *p = calloc(100, 1);
    p = "welcome";
    printf("%s\n", p);
    }
  10. A.
    Segmentation fault
    B.
    garbage
    C.
    Error
    D.
    welcome

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Memory allocation using malloc() is done in?
  12. A.
    Static area
    B.
    Stack area
    C.
    Heap area
    D.
    Both b & c

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Why do we write (int *) before malloc?
         int *ip = (int *)malloc(sizeof(int));
  14. 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

    Workspace

    Discuss Discuss in Forum


  15. Which one is used during memory deallocation in C?
  16. A.
    remove(p);
    B.
    delete(p);
    C.
    free(p);
    D.
    terminate(p);

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following will return a result most quickly for searching a given key?
  18. A.
    Unsorted Array
    B.
    Sorted Array
    C.
    Sorted linked list
    D.
    Binary Search Tree

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to?
  20. A.
    NULL
    B.
    Other dynamically allocated memory
    C.
    The same deallocated memory location
    D.
    It points back to location it was initialized with

    View Answer

    Workspace

    Discuss Discuss in Forum