int *p=(int *)malloc(12);

Your question is whether calling free function with argument p will clear the remaining elements.

It won't Because free will clear the first location which is pointed by p. If you want to clear all locations that is allocated by malloc. you need to use loop you need to have the temporary pointer then freeing it then move to the next pointer.