Thread: standard deviation in need help!!!

  1. #1
    Registered User
    Join Date
    Feb 2004

    standard deviation in need help!!!

    Hello to anyone,

    median - there is no equation for median. It it the value such that there are an equal number of values larger and smaller. For an odd number of values, if they are sorted, it is value in the middle of the list. If there are an even number of values, it is the mean of the middle two grades.

    double median(int grades[], int num);

    This function takes as input, num, the number of grades in the array, and grades, a pointer to the array in main. It finds the median grade in the array and returns this value. The simplist way of finding the median is to sort the grades by value. Then you can find the index for the median grade by using the definition for median above (it will be the middle index if there are an odd number of grades, or you will have to average the two middle grades if there are an even number). You can use the bubble sort function to do the sorting.

    Here is my code if any one can help please

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    How about you tell us actually what you're having problems with, rather than force us to debug your entire program? Now then, had you actually read the forum rules, you'd have done so.

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2003
    This probably doesn't answer the question you are asking
    (which isn't that all that clear by the way) but one thing that
    struck me when looking at your code is that you need to be
    a bit more careful when the input to a function is int and the
    output is double or float. Take a look at this noddy example...
    #include <stdlib.h>
    #include <stdio.h>
    int main (void)
      int a = 3, b = 2;
      double c;
      c = a/b;
      printf("%d/%d = %f (mmm... )\n", a, b, c);
      c = (double)a / (double)b;
      printf("%d/%d = %f (ahh, that's better...)\n", a, b, c);
      return 0;
    As for how to calculate the median, the clue is in the question: ...
    sort the list ... find the middle value.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with standard deviation
    By belkins in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 11:04 PM
  2. Replies: 2
    Last Post: 08-13-2008, 08:02 AM
  3. Standard Deviation of an array of numbers...
    By Xenofizz in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2003, 10:48 PM
  4. arrays and standard deviation
    By bruceness in forum C Programming
    Replies: 1
    Last Post: 10-28-2002, 09:35 PM
  5. Standard Deviation in C++
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 09-14-2001, 11:09 AM