delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/16/04:33:04

From: Lyle <lpak1 AT NO_SPAMccds DOT cc DOT monash DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: random number?
Date: Sat, 16 Aug 1997 15:19:54 +1000
Organization: Monash Uni
Lines: 31
Message-ID: <33F5387A.E6072453@NO_SPAMccds.cc.monash.edu>
References: <33F3CA35 DOT 29B3 AT erols DOT com>
NNTP-Posting-Host: ascend-2-34.cc.monash.edu.au
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Matt McFadden wrote:
> 
> Hi,
> 
> How can I make a loop that returns or produces a random integer between
> 0-9 on each pass through the loop?
> 
> Thank you,
> Matt

hi,

whatever generates your random number, mod it;

ie

random_number() % 10

this then returns the 'remainder of dividing by ten" which can only be
0-9

cya
-- 
NOTE: Remove The comment "NO_SPAM" To Reply via Email!

-------------------------------[ **NEW ADDRESS**
lpak1 AT ccds DOT cc DOT monash DOT edu DOT au]
" Hello Chevra Kadish, You Kill 'em, We Chill 'em "            .----,
						               | oO |
	HTTP://www-personal.monash.edu.au/~lpak1/              | \/ |
		                                               `----'

- Raw text -


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