0

when we make ( 1+rand()%6 ) ,why it always get 6 6 6 5 5 ?? why this numbers ?

16th Sep 2016, 5:25 AM
sarakhaled
sarakhaled - avatar
3 Respostas
+ 5
rand() is random number generator .. %6 produces numbers between 0 to 5 and plus 1 will give u numbers between 1 to 6 .. ie random numbers between 1 to 6 .. simple !!
16th Sep 2016, 9:36 AM
Bhushan Gaikwad
Bhushan Gaikwad - avatar
0
rand () is used to generate random numbers so each time u compile u will get different answer.
16th Sep 2016, 8:05 AM
Kishor Prasad
Kishor Prasad - avatar
0
You have to seed your pseudorandom number generator.
16th Sep 2016, 8:23 AM
Zen
Zen - avatar