Thread: Min Max Sum Average median and Mode from an Array....Where to start...Lost

  1. #16
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    I am having problem understanding the random input into the array.
    Also, I must use a seed value of 20.

    Is this the appropriate code for this?

    mainArray[currPos] = 20 + rand()%41;

    Thanks in advance
    Last edited by djay86; 04-17-2012 at 05:17 PM.

  2. #17
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Code:
    for(i=0;i<SIZE;i++)
    mainArray[i] = 20 + rand()%41
    The for loop will loop it as many times as you choose SIZE to be.

  3. #18
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I think that calculation is wrong. If the minimum is 10 then it should be 10 and not 20.

    Also low + rand() % (high - low + 1) is clearest expression.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 02-23-2012, 11:02 PM
  2. mean, mode median calculation..
    By naspek in forum C Programming
    Replies: 2
    Last Post: 09-10-2009, 09:15 AM
  3. Mean, Median, and Mode .....code
    By AdamLAN in forum C++ Programming
    Replies: 2
    Last Post: 10-22-2004, 02:29 PM
  4. Finding Mode Median and Mean
    By Ginny Morgan in forum C Programming
    Replies: 3
    Last Post: 05-08-2003, 03:09 PM
  5. median mode
    By bobbydigital in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2003, 08:53 PM