0

Afternoon:

I am trying to create a loop to give me a series of random numbers. I need the random numbers to be between 100 and 999, this is necessary so I can divide the numbers by 1000 and then use this numbers for another program. My problem is that random numbers give you numbers that are way big and not between 100 and 999. I create this code but it gives me a segmentation fault when I try to run it. Can anyone give me insight of where I made a mistake.

Thanks

G

```
#include <iostream>
using namespace std;
int number_generator();
int main()
{
int series;
cout << "How long you want your series: ";
cin >> series;
for (int i=0; i<series; i++)
{
number_generator();
}
}
int number_generator()
{
double series_number;
int number_to_use = rand();
if (number_to_use > 999 && number_to_use < 1000)
{
cout << number_to_use << endl;
double actual_random_integer = number_to_use/1000;
//cout << actual_random_integer << endl;
if (actual_random_integer < 0.25)
{
series_number = 1;
}
else
{
series_number = -1;
}
// cout << series_number << endl;
}
else
{
number_generator();
}
}
```