Random number

This is a discussion on Random number within the C Programming forums, part of the General Programming Boards category; 1. How to generate 0 and 1 in a random way in C99? 2. How to generate any 2 number ...

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278

    Random number

    1. How to generate 0 and 1 in a random way in C99?
    2. How to generate any 2 number in a random way from 1 to n in C99?

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,622

  3. #3
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    278
    Anything can be done with inbuilt C functions please?
    I have no knowledge of random number generators! So cannot implement this without theoretical knowledge!

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    Anything can be done with inbuilt C functions please?
    srand() and rand() are part of the C standard library and can be found in <stdlib.h>.

    I have no knowledge of random number generators! So cannot implement this without theoretical knowledge!
    Do something about your ignorance by reading:
    Using rand()
    Random Numbers Tutorial
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    52
    and keep in mind that the "random" numbers from the rand() follow a uniform distribution.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. rapid random number generation problem
    By Newton in forum C Programming
    Replies: 17
    Last Post: 09-19-2008, 02:08 PM
  2. Random number in range generation.
    By hebali in forum C Programming
    Replies: 19
    Last Post: 03-04-2008, 09:46 AM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  4. random number tutorial
    By 7stud in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2005, 02:41 PM
  5. Random Number Generator
    By Ikurik in forum C++ Programming
    Replies: 16
    Last Post: 08-17-2003, 07:34 PM

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