Does anyone know how to write a (preferably) console app that would find the modal value of a set of data that you entered?

Its all good i figured it out -- heres the code:

#include <stdio.h>
#include <stdlib.h>

void insertionSort(float numbers[], int array_size);

int main() {
    int array_size;

    printf("how many numbers? ");
    scanf("%i", &array_size);

   float numbers[array_size]; 
   float modes[array_size/2]; 

   float num;
   int i;

   printf("numbers:\n");
   for(i = 0; i < array_size; i++) {
         scanf("%f", &num);
        numbers[i] = num;
    }

    insertionSort(numbers, array_size);

    float temp;
    int mode;
    mode = 0;



for(i = 0; i < array_size; i++) {
   if(i != 0) {
    temp = numbers[i];
    if(temp == numbers[i-1]) {
        mode ++;
        modes[mode] = numbers[i];
    }
   }
}

int z = mode + 1;

for(i = 1; i < z; i++) {
    printf("     %f\n", modes[i]);
}





scanf("%d", &i);

}

void insertionSort(float numbers[], int array_size)
{
  int i, j, index;

  for (i=1; i < array_size; i++)
  {
    index = numbers[i];
    j = i;
    while ((j > 0) && (numbers[j-1] > index))
    {
      numbers[j] = numbers[j-1];
      j = j - 1;
    }
    numbers[j] = index;
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.