Tech Support > Computers & Technology > Programming > generating random numbers in c
generating random numbers in c
Posted by Johannes Veerkamp on February 6th, 2004


hello,
i'm am complete newbie to c and in need to write an programm which generates
random numbers from 1 to 10. can anybody help me out with the correct code?

thanks


Posted by Paul E. Black on February 6th, 2004


"Johannes Veerkamp" <JVeerkamp@gmx.de> writes:

There are links to pseudo-random numbers generators at
http://www.nist.gov/dads/HTML/pseudo...NumberGen.html

-paul-
--
Paul E. Black (p.black@acm.org)

Posted by Thad Smith on February 6th, 2004


Johannes Veerkamp wrote:

The Standard C library function rand() generates pseudo-random integers
in the range 0 to RAND_MAX, where RAND_MAX is defined in stdlib.h.
Using your math to convert the results to the desired range.

Thad

Posted by Michael J. Fromberger on February 7th, 2004


In article <c00ftv$oop$1@sunu789.rz.ruhr-uni-bochum.de>,
"Johannes Veerkamp" <JVeerkamp@gmx.de> wrote:

Hi, Johannes,

The comp.lang.c FAQ list has some helpful tips on this subject:
http://www.eskimo.com/~scs/C-faq/q13.16.html

The whole FAQ is here, and is a useful read-through if you are learning
C:
http://www.eskimo.com/~scs/C-faq/top.html

Cheers,
-M

--
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA


Similar Posts