Monday, May 24, 2010

If we want the random # library function to produce a different seq. of values each time the program is run...

Which of the following should be used?????





a. setenv(rand());


b. fopen(srand());


c. srand(clock());


d. srand(time(NULL));

If we want the random # library function to produce a different seq. of values each time the program is run...
c or d. Whenever you randomize based on the NOW timestamp, you will get a true random number. This is especially true in a multi-processor environment, where you are seeking an array of random numbers, and multiple processes are interrupting your array building procedure.





Good luck and Happy Computing!
Reply:i dont know about c


but d works good


No comments:

Post a Comment