1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <cmath>
using namespace std;
double mean3(double n1, double n2, double n3);
double stdev3(double n1, double n2, double n3);
int main ()
{
double n1, n2, n3;
cout << "Enter three numbers: ";
cin >> n1 >> n2 >> n3;
stdev3(n1, n2, n3);
cout << stdev3(n1, n2, n3);
return 0;
}
double stdev3(double n1, double n2, double n3)
{
mean3(n1, n2, n3);
double sd = sqrt((1/3)*(pow((n1 - mean3(n1, n2, n3)),2)+pow((n2 - mean3(n1, n2, n3)),2)+pow((n3 - mean3(n1, n2, n3)),2)));
return sd;
}
double mean3(double n1, double n2, double n3)
{
double mean = (n1+n2+n3)/3;
return mean;
}
|