+ 1

how Does srand() and rand() works?

i can't understand it how it works to generate ramdom numbers.

27th Nov 2016, 2:49 PM
Carlo Palermo Mamuric
Carlo Palermo Mamuric - avatar
3 Respostas
+ 2
the answer is complex in simple words it has process that changes set of values to obtain result use that result to give output it uses time as seed so random output is according to time
27th Nov 2016, 3:10 PM
Sandeep Chatterjee
+ 1
in simple words rand() has a huge list of random numbers but each time we call it, the list is called in the same sequence, making it predictable. To make it truly random srand() is used. Every time you give srand() a different number as an argument, the rand() list will start from a different number. So we use the current time as an argument for srand(). Because time is continuously changing so the rand() list will also start every time from a different number and thus making it more random and unpredictable.
27th Nov 2016, 9:29 PM
Mohammed Maaz
Mohammed Maaz - avatar