Date: Fri, 16 Jul 1999 13:16:00 -0400 (CST) From: Mitchell Cifuentes To: djgpp AT delorie DOT com Subject: Re: ---Random question--- In-Reply-To: <7mnf45$pqb$2@cubacola.tninet.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id NAA02329 Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Fri, 16 Jul 1999, Börje Granberg wrote: > I know there are commands like rand() and random() but how do I get a random > number between 1 and 100? > > In BASIC it is easy because there you get a random (float) number between 0 > and 1 that you can multiplicate with 100 and add 1, but I dont see that > opportunity in C++ or have my eyes missed that part? > > > -- > /Börje > > > > > > Try this : rand() % 101 the above gives you the rest of divisio of rand()/101 (a number in the range 0-100