filling an array with 40 rand #'s
I would like to fill my array with the 40 numbers I generated randomly, but it doesn't seem to be working right. Here is the code:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int i, r, x, ref[39];
unsigned seed;
printf("Enter seed: ");
scanf("%u", &seed);
srand(seed);
for( i=0;i<=39;i++){
printf("%10d", 1 + (rand() % 20));
r= 1 + (rand() % 20);
ref[i]=r;
}
printf("\nref[4] = %d", (ref[4]));
printf("\nThis is the complete ref string\n");
scanf("%d", &i);
return 0;
}