How to find mode from an array -


i have been trying prototype finding mode of array work not returning right thing, please tell me doing wrong.

  int mode(int array[], int size)   {       int x;       int mode = 0;       int largest = 0;       (x = 0; x < size; x++)      {          if (array[x] > largest)          {              largest = array[x];              mode = x;          }       }     return mode;    } 

first of if that's c++ arrays numbered 0, x should 0 in for. x should checked against < size. other code good.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -