Average of a set numbers by C++ Programme
AIM:
To find average of a given set of numbers by using C++ Programme.
REQUISITES:
A PC or laptop, Turbo C++ compiler installed in it.
THEORY:
For a data set, the terms arithmetic mean,
mathematical expectation, and sometimes average are used synonymously to refer
to a central value of a discrete set of numbers.
If x1,x2,x3…….xn are a set of data, the
mean can be calculated as
Xmean=Average=(x1+x2+………….+xn)/n
CODING:
#include<iostream.h>
#include<conio.h>
void main()
{
int a[100],sum=0,n,avg,i;
clrscr();
cout<<"Enter a number :";
cin>>n;
cout<<"Enter "
""<<n<<" ""numbers :"<<endl;
for (i=0;i<n;i++)
{
cin>>a[i];
}
for (i=0;i<n;i++)
{
sum=sum+a[i];
}
avg=sum/n;
cout<<"The average is:"<<avg;
getch();
}
OUTPUT:
Syllabus For: Get all B.Sc Physics Notes
- How to Prepare for IIT-JAM ⇠ ⇠ Click Here
- How to prepare for JEST ⇠ ⇠ Click Here
Post a Comment