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)
Define the term "mode". Specificly, what exactly are you trying to do?
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?