Average and standard deviation
Posted on 2005-04-27
Topic write a program that takes its input from a file of numbers of type doulbe. The program outputs to the screen the average and standard deviation of the numbers in the file. The file contains nothing but numbers of type doulb separated by blanks and or line breaks. The standard deviation of a list of number n1, n2, n3 and so forth is defined as the square root of the average of the following numbers.
a is the average of the number.
using namespace std;
void stdv (double n1, double n2, double n3, double n4, double avg);
if (in_stream.fail( ))
cout <<"Input file opening failed.\n";
if (out_stream.fail( ))
cout <<"Output file opening failed.\n";
double n1, n2, n3, n4;
out_stream <<"The average of the numbers are "<<((n1+n2+n3+n4)/4)<<endl;
This can produce the average but i dont know how to start wih deviation, can someone give me the correct way to do it.