Basically I need to create array eleements for an array using rand (). However whenever the code that I provide, the array is filled with the same random array. I am thinking that I need to do somehting with the count++ to get it to repeat. Can someone please help me out?
For example if I set minRange = 10 and MaxRange = 40
the mainArray becomes {11,11,11,11,11 ,11,11,11,11,11 ,11,11,11,11,11 }
Help please!
Shellina
Code:
void RandArray (int mainArray[], int count) {/*RandArray */ int minRange; // the minimum value the user decides for the array int maxRange; // the maximum values the suer decided for the array int randNum; // the random number generated // User sets MAX and MIN array values cout << "Minimum Value for the Array values: " ; cin >> minRange; cout << "Maximum Value for the Array values: " ; cin >> maxRange; randNum = (minRange + rand() % maxRange); // main loop to iterate numbers for (count = 0; count < ARRAY_SIZE; count++) { mainArray[count] =randNum; } }/* RandArray
the mainArray becomes {11,11,11,11,11 ,11,11,11,11,11 ,11,11,11,11,11 }
Help please!
Shellina
Comment