Help!! My last project of the year!! I'm almost done

This is a discussion on Help!! My last project of the year!! I'm almost done within the C++ Programming forums, part of the General Programming Boards category; I have this function in a separate file to be called in the main program. I know that i have ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Location
    Cincinnati, Oh
    Posts
    25

    Help!! My last project of the year!! I'm almost done

    I have this function in a separate file to be called in the main program. I know that i have to have a for statement under the first one where i already figured the sum. Please help.

    Code:
    //-----------------------------------------------------------------------------
    // deviation function
    //
    //-----------------------------------------------------------------------------
    	#include <cmath>
    	double deviation(double list[], int size)
    	{
    		double total=0;
    		double average;
    		double S;
    		double U;
    		double sum;
    		
    		for(int x = 0; x<size; x++){
    			total += list[x];
    		}
    		average = total/size;
    
    		for(
    		S = (sqrt (U / size));
    
    
    		return S;
    
    	}

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    So what do you need - the sum of square roots of each list[x] ?

    You already have a for loop dealing with list[x].
    If that is what you need to do again, what is the problem?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Location
    Cincinnati, Oh
    Posts
    25
    i found the average already but i need to figure the standard deviation of the array.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    So is this a math question then?

    Maybe do a google search for "How to calculate standard deviation"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Location
    Cincinnati, Oh
    Posts
    25
    Its a question of how do i write it in c++

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    calculate standard deviation - Google Search

    From Wikipedia
    1. Find the mean, \scriptstyle\overline{x}, of the values.
    2. For each value \scriptstyle x_i calculate its deviation \scriptstyle x_i \,-\, \overline{x} from the mean.
    3. Calculate the squares of these deviations.
    4. Find the mean of the squared deviations. This quantity is the variance σ2.
    5. Take the square root of the variance.
    You've done step 1, now try step 2.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  2. Final Year Graduation Project
    By PING in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 03-19-2008, 10:02 AM
  3. Determining the Date of the [nth] [Day] in [Month]
    By Dave_Sinkula in forum C Programming
    Replies: 5
    Last Post: 05-25-2007, 04:12 PM
  4. cant get code to work
    By duffy in forum C Programming
    Replies: 13
    Last Post: 10-20-2002, 05:23 AM
  5. Calender Control
    By iglod in forum Windows Programming
    Replies: 1
    Last Post: 09-14-2002, 06:38 AM

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