Welcome..!!

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

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;
}

1 comment:

  1. can you explain the codes please, the use of the variables.

    ReplyDelete