Is srand() neccessary because rand() will display random no. without srand()?????? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is srand() neccessary because rand() will display random no. without srand()??????

28th Oct 2016, 8:50 AM
koustav
koustav - avatar
2 Answers
+ 3
If you run program with rand() without srand(), it will generate same random numbers every time, so it is good to use srand(time(NULL)), because time changes every second. This causes generating different numbers every time you run your program.
28th Oct 2016, 9:22 AM
Daniel Oravec
Daniel Oravec - avatar
0
ok thanx😊
28th Oct 2016, 9:25 AM
koustav
koustav - avatar