Im working on a probability math problem where I need to print out how many triplets within the array are divisible by 5. my program compiles but I get get an error when I try to run the program. Not sure if my code is correct. I know its a little primative but I'm working with what little knowledge I have of the language. Any ideas why I cant run the program?

Code:

#include <stdio.h>
#include <stdlib.h>
int array[10] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
int main()
{
int a, b, x, i, j;
int tmp;
int count = 0;
for(j=0; j<120000; ++j)
{
for(x=0; x<50; ++x)
{
srand(time(NULL));
a = (rand() % (array[10] - array[0] + 1) + array[0]);
b = (rand() % (array[10] - array[0] + 1) + array[0]);
tmp = a;
a = b;
b = tmp;
i = array[0] + array[1] + array[2];
if(i%5==0) ++count;
}
}
printf("Count = %d\n", count);
getchar();
return 0;
}