Re: Random Integers


[Prev][Next][Index][Thread]

Re: Random Integers



Justin Smith wrote:
>
> In article <Pine.HPP.3.95.970904220239.3721B-100000@barney.gonzaga.edu>,
> Hermann Chong <hchong@gonzaga.edu> wrote:
>
> > I am writing a program, and I added a random integer in it.  It stayed at
> > one number, and I couldn't get it to be erratic.  How can I add that in?
>
> You need a random function in there, for example:
>
> rand *10
>
> To make it an integer, we need to adjust it a little to......
>
> round(rand*10,0)
>
> This will give you a random integer from 1 to 10.
>
> IF you want the random number range a bit higher, then just replace the 10
> with like 100 or something higher.
>
> Hope that helps.

Also, if you're using a 92, don't set the randseed() in the program.  If
you do, you will get that problem.  Set it once, then leave it alone,
and your numbers will come out randomly.

                                Notrub

--
"We must view with profound respect the infinite capacity of the human
mind to resist the introduction of useful knowledge."

                        --Thomas Raynesford Lounsbury
                          (1838-1915)
http://www.geocities.com/SiliconValley/Way/5423/
mailto:chriscrutch@geocities.com


References: