+ 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
3 Answers
+ 3
Here are some links that might help:
http://www.google.com/url?sa=t&source=web&cd=4&ved=0ahUKEwj85q7VzprQAhXoAcAKHZ_SDCIQFgglMAM&url=http%3A%2F%2Fwww.dreamincode.net%2Fforums%2Ftopic%2F55145-srand-and-rand%2F&usg=AFQjCNGtD4ohq3Hs_RsjNmqBzT6tKaXg4g
http://www.google.com/url?sa=t&source=web&cd=3&ved=0ahUKEwj85q7VzprQAhXoAcAKHZ_SDCIQFgghMAI&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F15188049%2Frand-and-srand-in-c&usg=AFQjCNF2LlOpy9JfjHN7sFwXsmQwMsGXPw
http://www.google.com/url?sa=t&source=web&cd=6&ved=0ahUKEwj85q7VzprQAhXoAcAKHZ_SDCIQFggsMAU&url=http%3A%2F%2Fwww.geekinterview.com%2Fquestion_details%2F56188&usg=AFQjCNHKllBHVJX-FOzNH3WWwjnw-VHerA
+ 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.
+ 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.