What is the difference between rand() and srand()??? please clarify... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the difference between rand() and srand()??? please clarify...

31st Jan 2016, 7:58 AM
RAVI KUMAR G
RAVI KUMAR G - avatar
3 Answers
+ 5
srand creates a seed that will be used by rand, you call srand only once in your program and you can use the current time to create a sead that rand will use e.g #include <ctime> int main { srand (time (0)); rand () return 0; }
7th Mar 2016, 7:43 PM
Tawanda Minya
Tawanda Minya - avatar
0
what do you mean by seeded random number??
22nd Jun 2016, 1:08 PM
Monic@
Monic@ - avatar
- 2
srand is a seeded random number
25th Feb 2016, 1:28 AM
sage cogar
sage cogar - avatar