delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/06/13:42:08

Date: Mon, 6 Dec 1999 13:30:46 -0500
Message-Id: <199912061830.NAA21908@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <82gnhb$dm2$1@imsp026.netvigator.com> (manman@netteens.net)
Subject: Re: Pls help!!
References: <82gnhb$dm2$1 AT imsp026 DOT netvigator DOT com>
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> printf("How much is %d times %d? ",1+(rand()%9),1+(rand()%9));
> ans=(1+(rand()%9))*(1+(rand()%9));

this code generates four random numbers.  What you need to do
is something like this:

a = 1 + (rand()%9);
b = 1 + (rand()%9);
printf("How much is %d times %d? ", a, b);
ans = a * b;

- Raw text -


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