Random number generator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sudhanshu
    New Member
    • Sep 2006
    • 17

    Random number generator

    Can anyone plz suggest me an idea to generate pseudo random numbers ?
    i tried using time function. can dis be done without using inbuilt functions?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Of course all you have to do is implement a pseudo random number generator algorithm much like the built in functions do.


    Lots of information here

    Comment

    • sudhanshu
      New Member
      • Sep 2006
      • 17

      #3
      Originally posted by Banfa
      Of course all you have to do is implement a pseudo random number generator algorithm much like the built in functions do.


      Lots of information here
      Thank you sir for the info.

      Comment

      • jerinjoy
        New Member
        • Sep 2006
        • 4

        #4
        use this:

        time_t seconds = time(NULL); //make sure this is declared at the beginning of the block
        srand(seconds);
        int a = rand();

        If you want to generate the same set of random numbers again and again then seed srand with the same number instead of seconds - ideally pass this as a command line argument or a define at the top of your code.

        Comment

        Working...