| | |
Random number generator
![]() |
•
•
Join Date: Aug 2008
Posts: 206
Reputation:
Solved Threads: 31
Look up the standard C functions in the C standard library, through <stdlib.h> or (in C++, through the <cstdlib> header). srand(int) is used to initially seed the generator. rand(), when subsequently called in a loop, produces pseudorandom integers in the range 0 to RAND_MAX.
Convert those integers returned from rand() to type double, and divide by RAND_MAX to get values in the range 0 to 1.
Convert those integers returned from rand() to type double, and divide by RAND_MAX to get values in the range 0 to 1.
Last edited by grumpier; Dec 27th, 2008 at 1:55 am.
Right 98% of the time, and don't care about the other 3%.
![]() |
Similar Threads
- Random number generator's (C++)
- using random number generator "globally" in a c++ class (C++)
- Gaussian Random number generator (C)
- Realy weird random number generator bug (C++)
- Random number generator (Java)
- Random number generator (Java)
- random number generator (C++)
Other Threads in the C Forum
- Previous Thread: a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.
- Next Thread: Code for Image Processing
| Thread Tools | Search this Thread |
* adobe api array arrays binarysearch calculate centimeter char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking hardware highest homework i/o ide inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation pattern pdf performance pointer posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h





