Thread: Random Number Array

  1. #1
    Registered User
    Join Date
    Sep 2006

    Random Number Array

    How does one set up an array of specific size, say 50 indexes, to have random variables in each index? Can't find how to do this.


  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    New York
    The naive, quick solution is to use srand and rand. Use these two functions to iterate through a static array of 50 elements and assign each element a value generated from rand.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Do a board search for "shuffle".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help regarding random number
    By Bargi in forum C Programming
    Replies: 6
    Last Post: 03-11-2009, 01:16 PM
  2. convert 32 bit number to array of digits
    By droseman in forum C Programming
    Replies: 11
    Last Post: 02-18-2009, 09:37 AM
  3. Create random array
    By Hunter_wow in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2007, 05:29 AM
  4. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  5. random number problems
    By lespaul5895 in forum C Programming
    Replies: 3
    Last Post: 07-05-2007, 02:16 AM