Create an array of integer using dynamic memory allocation. Insert first 10 prime number in the array and print.
#include <stdio.h>
#include <stdlib.h>
int main () {
int *a,size,i,j;
printf("Enter the size of array: ");
scanf("%d",&size);
a=(int*)malloc(size*sizeof(int));
if(a!=NULL){
printf("\nAllocation Successful\n");
}
for( i=2;i<=size;i++){
int count=0;
for( j=1;j<=i;j++){
if(i%j==0){
count++;
}
}
if(count==2){
*(a+i)=i;
printf("\t%d",*(a+i));
}
}
}