#include <iostream>
usingnamespace std;
constint N = 10;
class Stand_Devn
{
public:
double miu, sum;
void input(int num), mean(int num), sigma(int num);
double stand_devn(int num);
private:
double in[N];
};
void Stand_Devn::input(int num)
{
double in[N] = {0};
for (int i = 0; i < num; i++)
{
cout <<"Enter value "<< i+1 <<": ";
cin >> in[i];
}
//For testing purposes
cout << in[0] <<" "<< in[1] <<" "<< in[2] << endl;
}
void Stand_Devn::mean(int num)
{
double total = 0;
for (int i = 0; i < num; i++)
{
total += in[i];
}
double miu = total/num;
//For testing purposes
cout <<"Total: "; cout << in[0] + in[1] + in[2];
cout <<"\nMean: "<< miu;
}void Stand_Devn::sigma(int num)
{
double sum = 0;
for (int i = 0; i < num; i++)
{
sum += pow((in[i] - miu),2);
}
}
double Stand_Devn::stand_devn(int num)
{
cout <<"\nThe standard deviation for ";
for (int i = 0; i < num - 1; i++)
{
cout << in[i] <<", ";
}
for (int i = num; i , num + 1; i++)
{
cout << in[i];
}
cout <<" is: ";
return sqrt(sum/num);
}
void main()
{
Stand_Devn SD;
int count;
cout <<"Enter number of values (up to 10): ";
cin >> count; cout << endl;
SD.input(count); SD.mean(count); //SD.sigma(count); SD.stand_devn(count);
}
Enter number of values (up to 10): 3
Enter value 1: 1
Enter value 2: 2
Enter value 3: 3
1 2 3
Total: -2.77679e+062
Mean: -9.25596e+061Press any key to continue . . .