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:
printf("Please indicate how many numbers you wish to enter: ");
printf("Enter numbers: \n");
for(i=0; i<n; i++)
printf("Enter action:\n1. Get Mean\n2. Get Median\n3. Get Mode\n4. Exit\n");
printf("Option does not exist!\n");
int getMode(float numbers, int n)
int count = 1;
for(i=0; i <= n; i++)
for(j=1; (i+j)<=n; j++)
if(number[i] == numbers[i+j])
if((i+j) == n)
comp[i] = count;
count = 1;
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.