- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Arithmetic mean is the sum of a collection of numbers divided by the number of numbers in the collection.

The mean of

*n*numbers x1, x2, . . ., xn is x. If each observation is increased by*p*, the mean of the new observations is (x + p).The mean of

*n*numbers x1, x2, . . ., xn is x. If each observation is decreased by*p*, the mean of the new observations is (x - p).The mean of

*n*numbers x1, x2, . . ., xn is x. If each observation is multiplied by a nonzero number*p*, the mean of the new observations is px.The mean of

*n*numbers x1, x2, . . ., xn is x. If each observation is divided by a nonzero number*p*, the mean of the new observations is (x/p).

**Type 1**: Direct mean

Given the array and number of elements

**Input **- 1,2,3,4,5,6,7,8,9

**Output **- 5

**Explanation **- To calculate the 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**.

#include<iostream> using namespace std; int main(){ int n, i, sum=0; int arr[]={1,2,3,4,5,6,7,8,9}; n=9; for(i=0; i<n; i++) { sum=sum+arr[i]; } int armean=sum/n; cout<<"Arithmetic Mean = "<<armean; }

**Type 2**: Range and no of elements present I range is given.

Given three integers X, Y and N. Logic to find N Arithmetic means between X and Y.

N terms in an Arithmetic progression (no. of terms between X and Y)

X= first and Y= last terms.

**Input **- X = 22 Y = 34 N = 5

**Output **- 24 26 28 30 32

The Arithmetic progression series is

22 24 26 28 30 32 34

**Explanation**

Let X_{1}, X_{2}, X_{3}, X_{4}……X_{n} be N Arithmetic Means between two given numbers X and Y.

Then X, X_{1}, X_{2}, X_{3}, X_{4}……X_{n}, Y will be in Arithmetic Progression. Now Y = (N+2)^{th} term of the Arithmetic progression.

Finding the (N+2)^{th} term of the Arithmetic progression Series, where d is the Common Difference

Y = X + (N + 2 - 1)d Y - X = (N + 1)d

So the Common Difference d is given by.

d = (Y - X) / (N + 1)

We have the value of **A** and the value of the common difference(d), now we can find all the N Arithmetic Means between X and Y.

#include<stdio.h> int main() { int X = 22, Y = 34, N = 5; float d = (float)(Y - X) / (N + 1); for (int i = 1; i <= N; i++) { printf("%3f ", (X + i * d)); } return 0; }

24.000000 26.000000 28.000000 30.000000 32.000000

- Related Questions & Answers
- Arithmetic Mean in c++?
- Find Harmonic mean using Arithmetic mean and Geometric mean using C++.
- C++ Program for class interval arithmetic mean
- Arithmetic operators in Dart Programming
- What does # mean in Lua programming?
- What do you mean by Dynamic memory allocation in C programming?
- What do you mean by static memory allocation in C programming?
- Pointer Arithmetic in C/C++
- Arithmetic Operators in C++
- Character arithmetic in C
- Arithmetic Number in C++
- Arithmetic Slices in C++
- Longest Arithmetic Sequence in C++
- Verbal Arithmetic Puzzle in C++
- What are arithmetic operators in C#?

Advertisements