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.
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.
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.
Hope is the first step on the road to disappointment.
Do a search on this board, there have been many discussions on this topic. One such is this one.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
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.
Hey thanks alot guys, I really appreciate it.
hk_mp5kpdw thanks for the link, I would never have thought about using vectors.