random

This is a discussion on random within the C Programming forums, part of the General Programming Boards category; Could you send me the source code of "random" which used in C ? think you....

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    1

    Question random

    Could you send me the source code of "random" which used in C ?
    think you.

  2. #2
    Unregistered
    Guest
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>


    int main(void)
    {
    char key;
    int x ,counter=0;

    time_t t;
    srand(time( &t) );


    while(counter<10 ) /*allows ten user inputs*/
    {
    x = (rand () %(30+1)); /*limits range of rondom numbers*/
    printf("\n\tPress a Numerical Key for Random Number and press Enter : ");
    scanf ("%i", &key);
    printf("\n\tThe Random Number is: * %i *\n\n\t", x);
    counter++;
    }
    return 0;
    }

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Take a look at the FAQ. It has some good threads on it.
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random to int?
    By psyadam in forum C# Programming
    Replies: 7
    Last Post: 07-22-2008, 08:09 PM
  2. Lesson #3 - Math
    By oval in forum C# Programming
    Replies: 2
    Last Post: 04-27-2006, 08:16 AM
  3. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 04:51 PM
  4. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM
  5. Best way to generate a random double?
    By The V. in forum C Programming
    Replies: 3
    Last Post: 10-16-2001, 04:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21