how to generate a random number in c?

This is a discussion on how to generate a random number in c? within the C Programming forums, part of the General Programming Boards category; can anyone give me a sample code to generate a random number within a given number range....

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    24

    how to generate a random number in c?

    can anyone give me a sample code to generate a random number within a given number range.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    In your C documentation look up srand(), rand() and the % operator... I'm sure you can figure it out from there.

  3. #3

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do I generate a random number? (easily?)
    By fsx in forum C Programming
    Replies: 7
    Last Post: 05-12-2009, 06:04 AM
  2. Generate Random Number
    By peacealida in forum C++ Programming
    Replies: 10
    Last Post: 04-06-2008, 09:57 AM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 01:56 PM
  4. Replies: 2
    Last Post: 01-04-2004, 05:52 PM
  5. Generate random numbers in Lucky7 project using C#
    By Grayson_Peddie in forum C# Programming
    Replies: 1
    Last Post: 04-12-2003, 12:03 AM

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