You are viewing a single comment's thread. Return to all comments →
because you have allocated memory to pointer ar using malloc function before taking the value of n from user. you should first take input n from user and then allocate memory to the pointer, i.e.
first use scanf("%d",&n);
then write int ar=(int)malloc(sizeof(int)*n);
hope, you understand.