Difference between rand and srand | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Difference between rand and srand

what do u mean by random and truly random

30th Jul 2017, 1:57 PM
Romit Singh
Romit Singh - avatar
1 Answer
+ 6
srand() is used to seed the built-in RNG algorithm. rand() returns a 'random' integer. This is a replica of an RNG, and demonstrates how seeding works. https://code.sololearn.com/cMUCJqFL1X65/?ref=app To some point, true randomness cannot really exist. You can only produce a number which is difficult enough to predict, without a constant pattern.
30th Jul 2017, 2:32 PM
Hatsy Rei
Hatsy Rei - avatar