Memory Allocation

Q1: Point out the error in the following program.
#include<stdio.h>
#include<stdlib.h>

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

ANS:A - Error: unable to allocate memory

We should store the address in a[i]



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.