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

what is srand?

7th Oct 2016, 2:33 PM
nithish
3 Answers
+ 3
seed-rand, you will use this to set the random seed in the program for example srand(155); std::cout<<(rand()%100+1); the above will output 1-100 however since the seed is 155 every time it will output the same number, instead you can input time as the random seed using the ctime library. srand(time(0)); the above seed will give a different possible output everytime.
7th Oct 2016, 7:15 PM
Null Void
Null Void - avatar
0
yea relatively like that
22nd Nov 2016, 9:26 PM
AKIL
AKIL - avatar
0
a truly random function
28th Nov 2016, 7:54 PM
theunited broes
theunited broes - avatar