I have to create a vector of random numbers in a range of 0 to 250, and show which cousins are. This is my code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i,j,n[10];
srand(time(NULL));
for(i=0 ; i < 10 ; i++) {
n[i]=rand()%250;
printf("%d numero: %d\n",i,n[i]);
}
printf("\n");
for (i=0; i<10; i++) {
for (j=2; j<n[i]; j++) {
if (n[i]%j==0) {}
else
printf("O numero %d e primo\n",n[i]);
break;
}
}
}
I'm pretty sure there's something wrong with getting the rest of the division, but I do not know what it is.