www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/29/11:26:13

Xref: news2.mv.net comp.os.msdos.djgpp:8012
From: Francisco Javier Pena Pareja <i32japef AT sun630 DOT uco DOT es>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: random() and rand() question
Date: Thu, 29 Aug 1996 09:58:44 +0200
Organization: Centro Informatico Cientifico de Andalucia
Lines: 26
Message-ID: <Pine.SUN.3.91.960829095429.24833A-100000-100000-100000@sun630>
NNTP-Posting-Host: sun630.uco.es
Mime-Version: 1.0
In-Reply-To: <DwvF3A.H2r@interactive.net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp



On Wed, 28 Aug 1996, J.J. Pierson wrote:

> Silly question... How would I go about getting a random number from say 1
> to a specified number?
> 

It's quite simple. Let's suppose you want to get a random number from 0 
to 255. Then:

	rand()%256

will do that. From 1 to 255?

	rand()%255 + 1




	

UTOPIAN/Virtual Fantasies 


- Raw text -


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