Random integers

Tom Emerson tree at sun.soe.clarkson.edu
Sat Mar 18 06:19:57 AEST 1989


I'm sure this has an easy answer...

I need to generate a random integer between 1 and x.  How can this be done?
I have tried the following:

int k;
k = 10 * drand48();

But to now avail; I get a number that looks similar to 2274665.

Thanks in advance,

Tom Emerson
tree at sun.soe.clarkson.edu



More information about the Comp.lang.c mailing list