Difference in Unseeded rand() and seeded rand()

This is a discussion on Difference in Unseeded rand() and seeded rand() within the C++ Programming forums, part of the General Programming Boards category; Hello! Hey, im a beginning c++ student, and had a very complex, probably simple to you guys tho. I was ...

1. 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!

2. 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.

3. 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.

4. Imagine srand(1); happening behind your back...

5. It'd be like White Chapel all over again.

6. >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 ).