Help with displaying 1000 random numbers

Hey i need some help displaying 1000 random numbers between 1 - 100. the code i have here displays the same random number 1000 when i need 1000 different numbers. Any help someone could give putting me in the right direction would be grate. Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  #include <iostream>
#include <string>
#include <time.h>


using namespace std;

void randomizeSeed();
int randomRange(int min, int max);

int main()
{
	
	randomizeSeed();
	
	const int num = 1000;
	int Numbers[num] = {};
	const int minNumber = 1;
	const int maxNumber = 100;
	int randomNumber = randomRange(minNumber, maxNumber);



	for (int i = 0; i < num; i++)
	{
		
		cout << randomNumber << endl;
	}




	system("pause");
	return 0;
}

void randomizeSeed()
{
	srand(time(NULL));
}

int randomRange(int min, int max)
{
	int randomValue = rand() % (max + 1 - min) + min;
	return randomValue;
}
You get one random number on line 20 and output it num times in the loop beginning on line 24. Perhaps you should call randomRange more than one time?
Hey i figured it out here is the code thanks for your help


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <string>
#include <time.h>


using namespace std;

void randomizeSeed();
int randomRange(int min, int max);

int main()
{
	
	randomizeSeed();
	
	const int num = 1000;
	int Numbers[num] = {};
	const int minNumber = 1;
	const int maxNumber = 100;
	int randomNumber[1000] = {};
	
	
	for (int i = 0; i < num; i++)
	{
		randomNumber[i] = randomRange(minNumber, maxNumber);
		cout << randomNumber[i] << endl;
	}

	


	system("pause");
	return 0;
}

void randomizeSeed()
{
	srand(time(NULL));
}

int randomRange(int min, int max)
{
	int randomValue = rand() % (max + 1 - min) + min;
	return randomValue;
}
Topic archived. No new replies allowed.