Basic Computer Knowledge Test Questions and Answers

Tricky and Buggy Questions & Answers on malloc, calloc, free and realloc Calls – 2

1.

What is the output of this program?

  1.    #include<stdio.h>
  2. 
     
  3.    int main()
  4.    {
  5.        int *ptr;
  6.        ptr = (int *)calloc(1,sizeof(int));
  7.        *ptr = 10;
  8.        printf("%d\n",*ptr);
  9.        return 0;
  10.    }

   A.) 0
   B.) -1
   C.) 10
   D.) none of these

Answer: Option 'D'

none of these

Tricky and Buggy Questions & Answers on malloc, calloc, free and realloc Calls – 2 Download Pdf

Recent Posts