arrays and standard deviation

This is a discussion on arrays and standard deviation within the C Programming forums, part of the General Programming Boards category; hi, i am working on a program that reads grades of students into an array of type double and computes ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    5

    arrays and standard deviation

    hi, i am working on a program that reads grades of students into an array of type double and computes the mean and standard deviation after throwing out the highest grade and the lowest grade. The maximum number of students is 100. I have figured out how to get the max and min grades however i cannot figure out how to read all the grades into the array and then get the deviation, if anyone could give me some help on this i would appreciate it.

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    
    
    int maximum(double grades[], int n);
    /* Given an array of real numbers and the effective
    size of the array (i.e. count of the numbers in the
    array), this function returns the location of the
    highest number in the array */
    
    int minimum(double grades[], int n);
    /* Given an array of real numbers and the effective
    size of the array (i.e. count of the numbers in the
    array), this function returns the location of the
    lowest number in the array */
    
    void deleteElement(double grades[], int *n, int loc);
    /* Given an array of real numbers, the effective size
    of the array and the location of the element to be
    deleted, this function deletes that element from the
    array by shifting the rest of the elements one
    position to the left and decrementing the count by one
    */
    
    double mean(double grades[], int n);
    /* Given an array of numbers and the effective size of
    the array this function computes and returns the mean
    */
    
    double StandardDeviation(double grades[], int n);
    /* Given an array of numbers and the effective size of
    the array, this function computes and returns the
    standard deviation as described in the previous
    section */
    
    int main(void)
    
        double StandardDeviation = sqrt(sum/100);
        int n, loc, sum, i;
        double a[100];
        
        for (i=0; i<100; i=i+1){
        printf("Enter first grade:  ");
        scanf("%d" &n);
        a[i] = n;
        }
        /*finds the sum of all grades*/
        sum=0;
        for (i=0; i<=99; i=i+1)
            sum=sum = a[i];
    
        /*find minimun grade*/
       int Minimum( double grades[], int n ){ 
       int lowGrade = 100; 
       for ( int i = 0; i < n; i++ ); 
          for ( int j = 0; j < n; j++ );
             if ( grades[i][j] < lowGrade );
                lowGrade = grades[i][j]; 
       return lowGrade;
    }
    
           /* Find the maximum grade*/ 
       int Maximum( double grades[], int n ){ 
       int highGrade = 0; 
       for ( int i = 0; i < n; i++ );
          for ( int j = 0; j < n; j++ ); 
             if ( grades[i][j] > highGrade ); 
                highGrade = grades[i][j]; 
       return highGrade; 
    }
    
    
    output:
    
    Enter the first grade: 85
    Enter the next grade: 76
    Enter the next grade: 63.5
    Enter the next grade: 100
    Enter the next grade: 82
    Enter the next grade: 5
    Enter the next grade: 55
    Enter the next grade: -999
    
    The maximum grade is 100.00
    The minimum grade is 5.00
    
    The array contents after these values are deleted:
    
    85.00     76.00     63.50     82.00     55.00     
    
    The mean is   72.30
    The standard deviation is   11.36
    Code tags added by Hammer

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Direct your attention to the handy serach link in the upper right corner of this page. See that? This same homework question is posted weekly at least. You can benifit from all the same people who have asked the exact same question...

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to calculate standard deviation
    By hobilla in forum C Programming
    Replies: 13
    Last Post: 03-14-2009, 07:41 AM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-24-2004, 12:22 AM
  4. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 04:49 AM
  5. What is wrong with my sscanf function?
    By doampofo in forum C Programming
    Replies: 5
    Last Post: 03-09-2003, 10:42 PM

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