Hi frnds i need ur help.plz tell me by what seed values to be used to generate 1000 random nos using linear congruential method.(using c programing)
- posted
18 years ago
Hi frnds i need ur help.plz tell me by what seed values to be used to generate 1000 random nos using linear congruential method.(using c programing)
Wow are you in the wrong newgroup!
The following code was written in Visual C++ 6.0, but should compile fine on most computers (given u have a compiler, which if your reading this I assume you do). The program outputs three random values... /*Program displays three random integers.
*/ /* Header: iostream Reason: Input/Output stream Header: cstdlib Reason: For functions rand and srand Header: time.h Reason: For function time, and for data type time_t */ #include <iostream>#include <cstdlib>
#include <time.h>
int main() { /* Declare variable to hold seconds on clock.
*/ time_t seconds; /* Get value from system clock and place in seconds variable. */ time(&seconds); /* Convert seconds to a unsigned integer. */ srand((unsigned int) seconds); /* Output random values. */ cout<< rand() << endl; cout<< rand() << endl; cout<< rand() << endl; return 0; }
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.