+ 2
What is difference between srand() and rand(),also tell true random number and pseudo random number
2 Answers
+ 1
rand() = srand(1)
srand() allows you to set the starting point of the random number, so you can generate differing "random" results each time rather than having it output the exact same "random" numbers.
When I need a random number, I have it seed based upon the current time, as that's always a new value each time you run the program.
0
Also, I forgot to address your last question. Most things that we call "random" is really just "pseudo random." Even if it was true randomness, we would have to manipulate it so people feel like it's true random even though it is. For example, even if it's true random, humans are amazing at picking out patterns, and if they see the same number appear consecutively, what do they think? "This isn't random!" Sometimes an illusion is better than the real thing.
As well, true random is a lot more difficult than it sounds, because you have to create something "random" based upon something that isn't random at all. Probably the truest random is watching electrons pop in and out of existence, but if you knew how it works at its core, it's probably not random at all either, which brings us back to sometimes an illusion is better than the real thing.
As I mentioned in my original post, the closest I get to random is basing my randomness off the current time since it changes consistently.