I'm currently making a code that finds that mean, median and mode of a set of numbers given by the user.

My mean and median functions work just fine but I'm having problems with the mode.

Here are my main and mode functions:

Code:int main() { int n=0; int i=0; int choice=0; printf("Please indicate how many numbers you wish to enter: "); scanf("%d", &n); float numbers[n]; printf("Enter numbers: \n"); for(i=0; i<n; i++) { scanf("%f", &numbers[i]); } order(numbers, n); do { printf("Enter action:\n1. Get Mean\n2. Get Median\n3. Get Mode\n4. Exit\n"); scanf("%d", &choice); switch(choice) { case 1: getMean(numbers, n); break; case 2: getMedian(numbers, n); break; case 3: getMode(numbers, n); break; case 4: break; default: printf("Option does not exist!\n"); break; } }while(choice!=4); return 0; } int getMode(float numbers[], int n) { int i; int j; int count = 1; int comp[n][n]; for(i=0; i <= n; i++) { for(j=1; (i+j)<=n; j++) { if(number[i] == numbers[i+j]) { count++; } if((i+j) == n) { comp[i] = count; count = 1; } } } return 0; }

I'm planning on making my variable comp[] (which stores the count of frequency of numbers) a 2D array so that I can put the numbers beside it's frequency, but I'm not sure how I can assign the values to their respective position.

Help anyone?

Thanks!