Calculate arithmetic mean - C++ Program

Q. Write a C++ program to calculate arithmetic mean of numbers.

Answer:

Arithmetic mean is the sum of a collection of numbers divided by the number of numbers in the collection. Following program is calculating arithmetic mean of numbers.

#include<iostream>
using namespace std;
int main()
{
        int num, i, arr[50], sum=0;
        cout<<"\n How Many Numbers You Want to Enter? \n";
        cin>>num;
        cout<<"\n Enter "<<num<<" Numbers : \n";
        for(i=0; i<num; i++)
        {
                cin>>arr[i];
                sum=sum+arr[i];
        }
        int armean=sum/num;
        cout<<"\n Arithmetic Mean = "<<armean;
        return 0;
}


Output:

arithmetic mean