delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/16/11:34:48

Message-ID: <19990716153443.74661.qmail@hotmail.com>
X-Originating-IP: [207.172.36.189]
From: "Dr. |V|0lybd3nu|V|" <m0lybd3num AT hotmail DOT com>
To: djgpp AT delorie DOT com
Subject: Re: ---Random question---
Date: Fri, 16 Jul 1999 11:34:43 EDT
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com



>From: "Börje Granberg" <borje DOT granberg AT ebox DOT tninet DOT se>
>Subject: ---Random question---
>Date: Fri, 16 Jul 1999 15:55:44 +0200
>
>I know there are commands like rand() and random() but how do I get a 
>random
>number between 1 and 100?

DJGPP's version of random() produces a number between 0 and RAND_MAX.
To limit the range of random() to produce numbers 1-100, just use
(random()%100) + 1;

                                              Kirill Orlov


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019