# Difference in Unseeded rand() and seeded rand()

• 11-08-2005
relientk_man
Difference in Unseeded rand() and seeded rand()
Hello!

Hey, im a beginning c++ student, and had a very complex, probably simple to you guys tho. I was just wondering what the difference between a seeded random number generator and a unseeded random number generator in C++.

I ask this becuase i was assigned a program where an array stores 1000 numbers from each generator, then i have to pass the information to main to show and output.

Please, i really would like to know the answer so i can start coding!

Thanks!
• 11-09-2005
nvoigt
You can set the seed for the rand() funtion by calling srand() once before any calls to rand(). I guess omitting the call to srand() means it's unseeded.
• 11-09-2005
Thantos
rand() produces a series of numbers based off how its seeded. By using different seed values you get a different series of numbers. Saying it is unseeded is really a misnomer as it does have some default seed value. So by never calling srand() you will get the same series of numbers on every run of your program.
• 11-09-2005
Harbinger
Imagine srand(1); happening behind your back...
• 11-09-2005
SlyMaelstrom
It'd be like White Chapel all over again.
• 11-09-2005
Prelude
>I was just wondering what the difference between a seeded
>random number generator and a unseeded random number generator in C++.
The random number generator should still work, if that's what you're asking. If it's a very sophisticated RNG then it likely uses an array for seeding, in which case not seeding the generator could cause it to fail. In the case of less sophisticated generators, or generators with guaranteed semantics like std::rand, there's always a default seed and the generator will always work, but the default never changes so you'll get a predictable sequence (useful for debugging!). In the case of std::rand, the default seed is the same as if you called srand ( 1 ).