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
Post a Comment