# Answer to Question #16374 in C++ for Phillip

Question #16374
Write a program that takes as input three numbers and outputs the mean (average) and standard deviation of the numbers. If the numbers are x1, x2, and x3, then the mean(average) is x=(x1+x2+x3)/3 and the standard deviation is :

Your program must contain at least the following functions: a function that calculates and returns the mean and a function that calculates the standard deviation.
1
Expert's answer
2012-10-12T10:49:37-0400
#include <iostream>
#include <cmath>

using namespace std;
float numberOne;
float numberTwo;
float numberThree;
float mean;
float standardDeviation;
float calulatemean(){
mean = (numberOne + numberTwo + numberThree) / 4;
return mean;
}
float calculatestandarddeviation(){
mean=calulatemean();
standardDeviation = sqrt((pow(numberOne-mean,2)) + (pow(numberTwo-mean,2)) +

(pow(numberThree-mean,2))/ 3);
return standardDeviation;
}

int main ()
{
cout << "Input your first number :" ;
cin >> numberOne;
cout << "Input your second number:" ;
cin >> numberTwo;
cout << "Input your third number :" ;
cin >> numberThree;

cout << "The mean is " << mean << " and the standard deviation is " << calculatestandarddeviation() << "."
<< endl;
int k;
cin>>k;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be the first!

### Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS