Welcome..!!

Please visit http://csprograms.in/ for more Computer Science programs.

Showing posts with label average of. Show all posts
Showing posts with label average of. Show all posts

Wednesday, 14 March 2012

10. C++ program to find average of "n" numbers.


#include <iostream>
int main()
{
int i,n,m;
cout <<"Enter the total numbers \n";
cin >>n;
cout <<"The total number of array is \n"<<n;
for(i=1;i<=n;i++)
cin >>a[i];
m=0;
cout <<"The entered array is \n";
for(i=1;i<=n;i++)
cout <<"\n"<<a[i];
for(i=1;i<=n;i++)
m = m + a[i];
m = m / n;
cout <<" The average of 'n' numbers is \n"<< m;
return 0;
}