I want to write a function that will take an array of integers and determine the mode of those integers. Can anyone help out ?

If someone could show me an example I would be forever grateful.

Thanks a ton.

Printable View

- 07-28-2003-]SC[-DargothFinding the Mode of an integer array
I want to write a function that will take an array of integers and determine the mode of those integers. Can anyone help out ?

If someone could show me an example I would be forever grateful.

Thanks a ton. - 07-28-2003quzah
void foo( int bar[], int arraysize )

It's fairly simple. You'd be best served using two arugments, one to denote the size of the array you are passing.

Quzah. - 07-28-2003hk_mp5kpdw
Do a search on this board, there have been many discussions on this topic. One such is this one.

- 07-28-2003-]SC[-Dargoth
What I've set up is to prompt the "user" for the number of test subjects that were surveyed.

I then dynamically create the array of integers with that many elements.

I then prompt the user to input into the array the number of movies the test subjects watched.

I then calculate the average, median, and the mode of the values entered.

average(); works fine

median(); works fine

its the mode() that I'm just not getting. - 07-28-2003-]SC[-Dargoth
Hey thanks alot guys, I really appreciate it.

hk_mp5kpdw thanks for the link, I would never have thought about using vectors.