What is srand command ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is srand command ?

explain in brief..

12th Dec 2016, 6:52 AM
Anvesh
Anvesh - avatar
2 Answers
+ 3
bro run a program using rand. now look at output u will get random output. now run again the output would be exactly same as before. what does srand() do?? it takes in seed (any value) which alters the randomness. but if u seed any constant/variable inside srand then also output would be same. to deal with that we seed current time in srand which changes continuosly and hence we get truly random outputs
12th Dec 2016, 7:03 AM
manish rawat
manish rawat - avatar
+ 2
it is to tell compiler that rand ()is coming
12th Dec 2016, 7:00 AM
manish rawat
manish rawat - avatar