why we use seed for generate random numbers

sometimes people say that if you put seed blank this generates new sequence every time you want to get random numbers but if you entered the same seed you would get the same sequence ,what is seed and why we use with random number generator??
Can I get random numbers sequence with no repeat ,Does it called true sequence numbers when we have no repeated numbers?
With the standard rand(), reach random number is just a function of the previous. srand sets the first number, from which all others are generated. Thus the same seed produces the same numbers.
rand() will itself repeat rarely, as a repetition would make a cycle. rand() % X may repeat a lot though. If you want numbers from 1 to Y, without repetitions, the idea is to write those numbers in order into an array and then shuffle that array. There is a function random_shuffle() for that in <algorithm>.
There's no truly random number. What you get from the compiler is pseudo random. The compiler needs something to work with to generate numbers. So when you seed it, you are passing it an argument that gives it a different number to plug in to its algorithm. Most of us use the system clock because it's value changes every second giving us the illusion it's totally random.
what are you mean with pseudo random ?

Topic archived. No new replies allowed.