Random Number Generator - Error

Hey guys. I know little about programming. I have made this code with some help, but there is still a problem with it. I am basically trying to create a random number generator that will calculate the average of 1000 numbers and then go on and produce the average of square of those numbers, the cube, etc, up to power of 15. In this case I think I am missing a bracket around the j loop, but I am not sure where. Can anyone see it? I have to learn to really see the code through as well. Thank you.

Code:

`#include <stdio.h>`

#include <stdlib.h>

#include <time.h>

int main (int argc, char *argv[])

{

unsigned int iseed = (unsigned int)time(NULL);

srand (iseed);

int i,average; //defines i and average as integers

int j;

double x, y;

double ran;

double sum [15];

for (i=0; i<15; i++)

sum [i]=0;

for (j=0; j<1000; j++)

{

//printf ("%u\n", rand ());

x=y=(rand() / (RAND_MAX + 1.0));

for (i=0; i<15; i++) //error here averages less than 1

sum[i]+=y;

y=y*x;

}

printf("The Sum of Random Numbers : %d ", sum);

for (i=0; i<15; i++)

{

average=sum[i]/j; //j values retained from the loop (1000); alternatively: sum[15]

printf("The Average of Random Numbers : %d i=%d",average, i);

}

return 0;

}