I need to input from keyboard some random values and put them in an array. After that I need to print the average of the prime numbers only. This is my code but it doesn't work:
#include<stdio.h>
#include<conio.h>
int main()
{
int v[50], n, i, nrprim = 0, sum = 0, j;
float medie = 0;
printf("dati numarul de elemente al vectorului:\t");
scanf("%d", &n);
for ( i = 0; i < n; i++)
{
printf("dati elmentele vectorului:\t");
scanf("%d", &v[i]);
}
for(i=0; i<n; i++)
for(j=2; j<v[i]; j++)
{
if(v[i]%j!=0)
{
sum = sum + v[i];
nrprim++;
}
}
medie =( sum/nrprim);
printf("%f", medie);
_getch();
return 0;
}