From: Sormuras Newsgroups: comp.os.msdos.djgpp Subject: Re: [Q] Whats wrong here... Date: Tue, 07 Oct 1997 10:21:58 +0100 Organization: Rhein-Zeitung Lines: 54 Message-ID: <343A0D46.7383@GMX.net> References: <61canb$kjf$1 AT kurica DOT wt DOT com DOT au> Reply-To: Sormuras AT GMX DOT net NNTP-Posting-Host: pppin150.koblenz.rhein-zeitung.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Robert Debeljakovic wrote: > > Ok, look at the following code.... > ---------------------------------------------------- > #include > #include > #include > > void Random(int MaxValue) > { > int x; > > x= -1; > if((x < 0)||(x > MaxValue)) > x=rand(); > printf("[%d]\n",x); > } > > void main(void) > { > int i; > printf("Press return to get 10 numbers between 0-100\n"); > getch(); > for(i=0;i<10;i++) > Random(100); > printf("\n"); > getch(); > } > ------------------------------------------------------------------ > > Why does it keep giving me HUGE numbers? > Please help this BLIND man see!!! > > Cheers, > Robert Debeljakovic. > West Oz Try this for getting 10 random numbers between 0..100 ... for (i=0; i<10; i++) { printf("[%d]\n",random%100); } ... -- Sormuras. +--------------------------------------------------+ / // // //// /// // / / // /| *--------------------------------------------------+/| | e-mail : Sormuras AT GMX DOT net |/+ | homepage : http://homes.Rhein-Zeitung.de/~kstein |/ +--------------------------------------------------+