C++ Program to Calculate Arithmetic Mean

« Previous Program Next Program »

Calculate Arithmetic Mean in C++

To calculate arithmetic mean of numbers in C++ Programming, you have to ask to the user to enter number size then ask to enter the numbers of that size.

To calculate arithmetic mean of all numbers, first perform addition of all the numbers, then make a variable responsible for the arithmetic mean and place addition/size in a variable say armean (arithmetic mean), then display the result on the output screen as shown here in the following program.

C++ Programming Code to Calculate Arithmetic Mean

Following C++ program ask to the user to enter the number size (say n), then ask to enter n numbers to calculate and display the arithmetic mean of all the numbers:

/* C++ Program - Calculate Arithmetic Mean */
void main()
	int n, i, arr[50], sum=0;
	cout<<"How many number you want to enter ?\n";
	cout<<"Enter "<<n<<" Numbers :";
	for(i=0; i<n; i++)
	int armean=sum/n;
	cout<<"Arithmetic Mean = "<<armean;

When the above C++ program is compile and executed, it will produce the following result:

C++ program arithmetic mean

Same Program in Other Language

You may like the same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test