I have randomized an array of 1000 to fill with numbers 10-50. I need to find the median and mode. Since it was randomized I know i need to sort the array then find the median and mode, yet im unsure how to do that, please help.
This is what i have so far...
This is what I have for the sort so far but it isnt sorting them...Code:#include <stdio.h> #include <stdlib.h> int main () { int mainArray[1000]; int size = 1000; int currPos = 0; int randNumber = 0; srand(20); for (currPos = 0; currPos < 1000; currPos++) { mainArray[ currPos ] = rand()%41+10; } }
Code:int i; int n; int num1, num2; for (i = (size - 1); i > 0; i--) { for (n = 1; n <= i; n++) { if (mainArray[(n-1)] > mainArray[n]) { num1 = n-1; num2 = n; } } }