I am trying to use a random number generator (RNG) to fill in the array.
The array is 25 numbers long and i want the the random number generator to create the numbers and then using a FOR loop to fill in the arrays.
# include <iostream>
# include <cstdlib>
# include <ctime>
usingnamespace std;
int main ()
{
int a[25];
int i;
int b;
srand (( unsignedint ) time ( NULL ) );
for ( i = 0; i < 25; i++ )
{
cout << "Number is: " << rand ( ) % 100 << endl;
a[i] = rand() % 100;
}
for (i=0; i<25; i++)
cout << a[i] << endl;
return 0;
}
The problem i am having is the numbers in the array are not the same as the original numbers created by the RNG?
I list the original random numbers created in the first FOR loop then i try to list them again in the second FOR loop but they are not the same numbers?
How do i get the two FOR loops to produce the same numbers?
Thanks