Top

Discussion

Point out the error in the following program.

#include
#include

int main()
{
    int *a[3];
    a = (int*) malloc(sizeof(int)*3);
    free(a);
    return 0;
}

 

  • A.Error: unable to allocate memory
  • B.Error: We cannot store address of allocated memory in a
  • C.Error: unable to free memory
  • D.No error

Answer: B

We should store the address in a[i]

 

No comment is present. Be the first to comment.
Loading…

Post your comment