Mail Archives: djgpp/1997/10/07/08:30:42
Robert Debeljakovic wrote:
>
> Ok, look at the following code....
> ----------------------------------------------------
> #include <stdio.h>
> #include <stdlib.h>
> #include <conio.h>
>
> 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("<press any key to continue>\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 |/
+--------------------------------------------------+
- Raw text -