What is the difference between rand and srand | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

What is the difference between rand and srand

I mean why is one pseudo and the other different Random is there any difference in the results probability distribution

9th Nov 2016, 2:16 AM
Sandeep Chatterjee
3 Answers
+ 5
it's not that srand is truly random. srand is just used seed the rand() function. Although they, don't look to be connected. rand() generates sequence of "pseudo random" nos using some algo and srand sets pointer over a particular no which changes according to the seed value.
9th Nov 2016, 4:27 AM
kamal joshi
kamal joshi - avatar
+ 3
thanks to all. thanks to Aquarius the links helped. kamal I realised the mistake in my question as pointed by you srand is not true random it is seeded random.
9th Nov 2016, 6:44 AM
Sandeep Chatterjee