3 array questions

Questions:
1- why my cout = array + 1? In other words, why im getting one random number more than the array allocation.
2- how i can get a unique set of random number allocate in the array?
3- how i compare the numbers allocate in the array?
some examples with comments are very welcome.

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
void Gen::UserMax()
{
	cout << "Enter the maximum number of random numbers to generate: ";
	cin >> userMax;
}
void Gen::DigitMax()
{
	cout << "Enter the maximum number of digits each random numbers contains: ";
	cin >> digitMax;
}

void Gen::generatorRandoms()
{
	srand(time(0));
	int modNumber = 0;
	int randomNumber = 0;
	int j = 0;

	if (digitMax == 2)
	{
		modNumber = 100;
	}
	for ( int i = 0; i< userMax; i ++)
{ 
	randoms[j]=rand() % modNumber;
	if ( randoms[j] <=10)// Control minimum number of digits
	{
	i--;
	}
	if ( randoms[j] >=10)// Control maximum number of digits
	{
	cout<< randoms[j]<< "\t";
	} 
}	
}
Last edited on
Topic archived. No new replies allowed.