# Statistics with C++...
#1 ) C++ program to calculate arithmetic mean for NORMAL DISTRIBUTION...
/* This Program will calculate mean IQ of students based on given IQs. */
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
class AMean
{
public: int A[];
int n;
public: void GetData();
void Mean();
};
void AMean :: GetData()
{
cout<<"\nEnter total number of students : ";
cin>>n;
cout<<endl;
cout<<"\nEnter the IQ of "<<n<<" students : ";
cout<<endl;
cout<<endl;
for(int i=1;i<=n;i++)
{
cout<<"IQ of student number "<<i<<" = ";
cin>>A[i];
}
}
void AMean :: Mean()
{
int Sum = 0;
for(int j=1;j<=n;j++)
{
Sum += A[j];
}
cout<<endl;
cout<<"Mean IQ = " <<Sum<<" / "<<n;
float MeanIQ = (float)Sum/n;
cout<<endl;
cout<<endl;
cout<<"Mean IQ = "<<setprecision(2) <<MeanIQ;
}
void main()
{
AMean AM;
clrscr();
AM.GetData();
AM.Mean();
getch();
}
------------------------------------------------------------------------------------------------------------
OutPut :
------------------------------------------------------------------------------------------------------------
* Plz comment if you find ERRORS or Corrections.....
Happy Coding!
No comments:
Post a Comment