"Z Code Writer" is an Online Blog for Programmer & Beginner. Here, You will Find tech, Build your Programming Skills and other Programming Language Like C, C++, HTML, Java Script Java Code, Web Designing and University Of Sialkot (USKT) CGPA / GPA Calculator etc.

Thursday, 16 July 2020

Find Mean in UnGroup Data in C\ C++ Program

What is Mean ?

        Mean is define as the sum of all observed data divided by total number. The mean or arithmetic mean is average of group measure. It is also called Arithmetic Mean.

Mean in Ungroup Data

        In Ungroup Data, we have only given data X that means we solve this Array of data.  Formula of  Mean on in group Data:

Arithmetic Mean Formula of ungroup Data
Here n is the total number of X.

Program in C / C++

#include<iostream>
using namespace std;
int main(){
float x[10],num,sum=0,mean;
cout<<"Enter Total Number ";
cin>>num;
cout<<"X"<<endl;
for(int i=0;i<num;i++){
cin>>x[i];
sum=sum+x[i];
}
cout<<"Sum: "<<sum<<endl;
mean=sum/num;
cout<<"Mean = Sum(x)/n = "<<mean;
return 0;
}

Input: 
X: 5, 10, 15, 20, 25

Output: 


Arithmetic Mean in UnGroup Data

Mean in Group Data

    In Group Data, we have given data Class interval and frequency (f). Formula of mean group data.
Arithmetic Mean Formula of group Data

Step 1: Find X of every index.
X= lover Class interval + Higher Class interval /2
Step 2: find F*X.
we simply multiply every index f*x and Sum of all F*X.
Step 3: Sum of F.

Program in C /C++


#include<iostream>
using namespace std;
int main(){
float x[10],fx[10],num,sumf=0,sumfx=0,mean;
float start[10],end[10],f[10];
cout<<" \t\t <<----- Mean Of Group Data ----->> "<<endl<<endl<<endl;
cout<<"Enter Total Number ";
cin>>num;
cout<<"Enter Class Intrvals"<<endl;
for(int i=0;i<num;i++){
cout<<i+1<<"- Range Start ";
cin>>start[i];
cout<<i+1<<"- Range End ";
cin>>end[i];
cout<<i+1<<"- Enter Frequency of this Range ";
cin>>f[i];
}
for(int i=0;i<num;i++){
sumf=sumf+f[i];
x[i]=(start[i]+end[i])/2;
fx[i]=f[i]*x[i];
sumfx=sumfx+fx[i];
}
cout<<"Class Interval Frequency\tX\tF*X"<<endl;
for(int i=0;i<num;i++){
cout<<start[i]<<" - "<<end[i]<<"\t\t"<<f[i]<<"\t\t"<<x[i]<<"\t"<<fx[i]<<endl;
}
cout<<endl;
cout<<"Sum(F)  = "<<sumf<<endl;
cout<<"Sum(FX) = "<<sumfx<<endl;
mean=sumfx/sumf;
cout<<"Mean = Sum(fx)/Sum(f) = "<<mean;
return 0;
}

Input:
Class Interval  |  Frequemcy
5-10                 |          8
11-15               |          16
16-20               |          2
21-25               |          5
26-30               |          10

Output
Arithmetic Mean in Group Data

No comments:

Post a Comment

Thanks For Visiting Here...!! I will Reply you as soon as possible.