+ 1
use while loop instead of for loop for random number generation?
per the for loop example for generating random numbers.... appreciate the help.
3 ответов
+ 1
for (int i = 0; i <10; i++)
cout<<rand() % 100 + 1; // rand in the range 1 to 100;
..is the same as...
int i = 0;
while (i < 10)
{
cout<<rand() % 100 + 1; // rand in the range 1 to 100;
i++;
}
..the both print 10 random numbers between 0 and 100.
+ 1
Thank you
+ 1
Thank you for sharing Josh. it makes it easier to understand.