delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/27/18:29:02

Message-ID: <018801bfc877$2a916ba0$0100a8c0@ivan>
From: =?iso-8859-1?Q?Grzegorz_Pato=B3a?= <gpatola AT lemon DOT ia DOT polsl DOT gliwice DOT pl>
To: <djgpp AT delorie DOT com>
References: <392CB951 DOT 34B432E6 AT chemistry DOT uq DOT edu DOT au>
Subject: Odp: Random numbers
Date: Sun, 28 May 2000 00:31:55 -0700
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2417.2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Reply-To: djgpp AT delorie DOT com

Chris Miller wrote:

> If RAND_MAX is set to 100, then a call to rand() should return an
> integer between 0 and 100.  However, on my computer, a call to rand()
> generates a number between what appears to be hundreds of millions and
> 0, even with RAND_MAX set to 100.


You can try sth like this:

int lotto;
lotto = rand() % 100;

of course if you want to get numbers between 0 and 100...

________________________________________
Grzegorz Patola
email: ivan AT zeus DOT polsl DOT gliwice DOT pl
Alternative email: gpatola AT lemon DOT ia DOT polsl DOT gliwice DOT pl
ICQ# 1448779


- Raw text -


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