Mode?

This is a discussion on Mode? within the C++ Programming forums, part of the General Programming Boards category; I have a problem concering modes. I was asked to determine the mode of an array which the user inputs. ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    5

    Question Mode?

    I have a problem concering modes. I was asked to determine the mode of an array which the user inputs. I am supposed to write a function that accepts an array of integers, and an integer that indicates the number of elements in the array. The mode is the value the function returns, if no mode then return -1. I have not figured the correct way to detemine the mode yet.

    Any help would be greatly appreciated!!

    (mode was defined as any number that occurs more than one in the array, if none than a value of -1 would be returned)
    SORRY!!!
    Last edited by George; 02-06-2003 at 04:13 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Define the term "mode". Specificly, what exactly are you trying to do?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Try using a loop through the array that checks to see the current number exists somewhere else in the array, and if so return it. If none exist, return -1. Although I'm not sure what you plan on doing if there is more than one mode, isn't mode defined as the number that appears the most?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. console mode and service mode
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 06-01-2008, 02:42 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Shortening main
    By pdstatha in forum C Programming
    Replies: 1
    Last Post: 04-03-2002, 04:56 PM
  4. Implementing "ls -al"
    By pdstatha in forum Linux Programming
    Replies: 11
    Last Post: 03-20-2002, 04:39 AM
  5. free() usage
    By pdstatha in forum C Programming
    Replies: 5
    Last Post: 03-13-2002, 09:28 AM

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