>From: Johnathan Smith <[EMAIL PROTECTED]>
>Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>Subject: Random number from 1 to 15
>Date: Wed, 12 Dec 2001 12:21:23 -0800 (PST)
>
>Can someone please show me how to make a random number
>from 1 to 15

How about this? I used the DJGPP DOS port of gcc. It should work with gcc 
for the Palm. It would be a good idea to seed the RNG (from the current 
time?) so you get a different sequence each time it is run.

/*
** random.c
**
** generate random number between 1 and 15
** uses gcc non-ANSI function random()
*/

#include <stdio.h>
#include <stdlib.h>

main()
{
        int x;

        for (;;)
        {
                x = (random() % 15) + 1;                        printf("%d ", x);

        }
}


Leon
--
Leon Heller, G1HSM Tel: +44 1327 359058 Email:[EMAIL PROTECTED]
My web page: http://www.geocities.com/leon_heller
My low-cost Altera Flex design kit: http://www.leonheller.com


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to