
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Arithmetic Mean in c++?
The Arithmetic Mean is just the average of numbers. In this program we will see how we can find the arithmetic mean from a set of numbers. The function will take the number set, and the number of elements. Out task is just adding each element, then divide it by number of elements that are passed.
Algorithm
arithmeticMean(dataset, n)
begin sum := 0 for each element e from dataset, do sum := sum + e done return sum/n end
Example
#include<iostream> using namespace std; float arithmetic_mean(float data[], int size) { float sum = 0; for(int i = 0; i<size; i++) { sum += data[i]; } return sum/size; } main() { float data_set[] = {25.3, 45.21, 78.56, 96.21, 22.12, 36.97}; cout << "Mean: " << arithmetic_mean(data_set, 6); }
Output
Mean: 50.7283
- Related Articles
- Arithmetic Mean in C programming
- Find Harmonic mean using Arithmetic mean and Geometric mean using C++.
- C++ Program for class interval arithmetic mean
- What Is Arithmetic Mean?
- C++ code to find minimum arithmetic mean deviation
- Find the Arithmetic mean of first 10 natural numbers
- 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#?
- Arithmetic Slices II - Subsequence in C++

Advertisements