The program I have is as follows:
I am trying to get both arrays to return random numbers, but the only numbers that appear truly random are those of the second array. I don't understand why this is, as they are both programmed the same. Can anyone point me to my error and how to correct it?Code:#include <stdio.h> #include <time.h> #include <stdlib.h> #define SIZE 4 int main() { int a=0,b=0; int x[SIZE]; int y[SIZE]; srand(time (NULL)); for( a=0; a<SIZE; a++ ) { x[a] = 1 + (rand() %10); for( b=0; b<SIZE; b++ ) { y[b] = 1 + (rand() %10); printf( "[%d][%d] ", x[a], y[b] ); } printf( "\n" ); } scanf("%d"); return 0; }
Thank you very much for your time,
Brent