reubenhyman
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by reubenhyman
-
-
Just getting into C++ I'm experimenting with random number generator
How is it that I would sometimes get the same number?
srand(time(0));
I have int as
int randNumb1 = 0;
int randNumb2 =0;
so it do this
randNumb1 = (rand() % 20) +1;
cout << "First Random number is " << randNumb1 << endl;;
randNumb2 = (rand() % 20) +1;
while (randNumb1 = randNumb2) {
randNumb2 = (rand() %20) +1;
cout << "Second number is " << randNumb2 << endl;;
// terminate the loop
break;
}
C++
in General
Posted · Edited by reubenhyman
when I place the == comparison operator and comment out the break instead of = it only displays 1 number
does not show second number