+ 1

use while loop instead of for loop for random number generation?

per the for loop example for generating random numbers.... appreciate the help.

25th Jan 2017, 6:43 PM
Mich
Mich - avatar
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.
25th Jan 2017, 7:55 PM
Josh Davidson
Josh Davidson - avatar
+ 1
Thank you
25th Jan 2017, 7:56 PM
Mich
Mich - avatar
+ 1
Thank you for sharing Josh. it makes it easier to understand.
27th Jan 2017, 11:06 PM
Mich
Mich - avatar