standard deviation in need help!!!

This is a discussion on standard deviation in need help!!! within the C Programming forums, part of the General Programming Boards category; Hello to anyone, median - there is no equation for median. It it the value such that there are an ...

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    3

    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
    Attached Files Attached Files

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    143
    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...
    Code:
    #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.
    DavT
    -----------------------------------------------

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-29-2008, 12:04 AM
  2. Replies: 2
    Last Post: 08-13-2008, 09: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, 12:09 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21