0

rand() is giving same output?

If rand() function gives random no. than why its giving output 41 everytime i execute the code.

26th Aug 2017, 8:33 AM
Samarth Bhardwaj
Samarth Bhardwaj - avatar
2 Answers
+ 9
Because most likely you forgot to seed your random number generator. srand( (size_t) time(0) );
26th Aug 2017, 8:36 AM
Babak
Babak - avatar
0
thankyou guys 👍
26th Aug 2017, 11:59 AM
Samarth Bhardwaj
Samarth Bhardwaj - avatar