- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the C++ program below,we ask 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:
Source Code: Calculate Arithmetic Mean in C++
/* C++ Program - Calculate Arithmetic Mean using Array */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int n, i, arr[50], sum=0; cout<<"How many number you want to enter ?\n"; cin>>n; cout<<"Enter "<<n<<" Numbers :"; for(i=0; i<n; i++) { cin>>arr[i]; sum=sum+arr[i]; } int armean=sum/n; cout<<"Arithmetic Mean = "<<armean; getch(); }Output
How many number you want to enter ? 10 9 8 7 6 5 4 3 2 1 Arithemetic Mean = 5