How c++ puts any random value by its own? How it manipulates? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How c++ puts any random value by its own? How it manipulates?

25th Dec 2016, 6:06 AM
samyak
3 Answers
0
check out my code fun with random nos with comments for help, if still getting doubts comment on the code , I ll add more examples and comments to help better understand
25th Dec 2016, 6:43 AM
Morpheus
Morpheus - avatar
0
use srand(time()) in your program once. use <ctime> and <cstdlib> as header. then use rand%10 for example.
25th Dec 2016, 8:30 AM
Kourosh Azizi
Kourosh Azizi - avatar
0
Pretty much like anything else electronic I believe. Takes the timestamp (or any number AS seed) and through some arbitary math it puts out a pseudo-random number.
25th Dec 2016, 1:59 PM
Norbivar
Norbivar - avatar