Just a small addition to the above post.
When ever you declare arrays dynamically you must
int main()
{
int *arr =(int *)malloc(sizeof(int)*10);
if(!arr){
// Check if you did get the memory you asked for
printf("No memory. Terminating program\n");
exit(1);
}
else{
printf("Sufficient memory found\n");
}
// Do operation on the array here
free(arr); // Free the memory that was given to you after you are done using it
return 0;
}