Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>rand() get pseudorandom integer</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 rand()                  Get Pseudorandom Integer

 #include   <stdlib.h>                   Required for declarations only

 int        rand(void);

    rand() returns a pseudorandom integer; the number returned is in the
    range 0-32767.

    Returns:    A pseudorandom number in the range 0 to 32767 (maximum
                signed integer size); no error return.

      Notes:    A random starting point can be set by calling srand()
                before calling rand().

   -------------------------------- Example ---------------------------------

    The following statements generate 10 random numbers in the range 0 to
    32767 and print them out.

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

           int i;

           main()
           {
                printf("     RANDOM NUMBERS \n");
                for (i = 1; i <= 10; i++)
                    printf("index: %d,  random number: %d \n",i,rand());
           }


See Also: srand()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson