In C programming, arithmetic mean
The arithmetic mean is the sum of a set of numbers divided by the number of numbers in the set.
Basic properties of the arithmetic mean
-
n The average of the numbers x1, x2,. . .,xn is x. If each observation is increased by p, then the mean of the new observations is (x p).
#n Numbers x1, x2, . . .,xn is x. If each observation is reduced by p, then the mean of the new observations is (x - p).
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.
#n average of em> 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).
Arithmetic mean formula
Type 1: Direct average
Given 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 add all the numbers, then create a variable responsible for the arithmetic mean and put the addition/size into the variable like armean .
Example
#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: Given range and number of elements present.
Given three integers X, Y and N. Find the arithmetic mean of N between logical X and Y.
N terms in an arithmetic series (the number of terms between #- Explanation
Suppose X1
, X2, X3
, X4
……Xn is the arithmetic mean between N two given numbers X and Y.
Then X, X1, X2, X3, Y will be in an arithmetic series. Now Y = the (N 2)th term of the arithmetic series. Find the (N 2)th term of the arithmetic series where d is the tolerance
X= first and Y= last terms.
22 24 26 28 30 32 34
Y = X + (N + 2 - 1)d Y - X = (N + 1)d
d = (Y - X) / (N + 1)
The above is the detailed content of In C programming, arithmetic mean. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











We all know numbers that are not the square of any number, such as 2, 3, 5, 7, 8, etc. There are N non-square numbers, and it is impossible to know every number. So, in this article, we will explain everything about squareless or non-square numbers and ways to find the Nth non-square number in C++. Nth non-square number If a number is the square of an integer, then the number is called a perfect square. Some examples of perfect square numbers are -1issquareof14issquareof29issquareof316issquareof425issquareof5 If a number is not the square of any integer, then the number is called non-square. For example, the first 15 non-square numbers are -2,3,5,6,

In this article, we will learn about the reversal algorithm to rotate a given array to the right by k elements, for example −Input:arr[]={4,6,2,6,43,7,3,7},k= 4Output:{43,7,3,7,4,6,2,6}Explanation:Rotatingeachelementofarrayby4-elementtotherightgives{43,7,3,7,4,6,2,6}.Input:arr[]={8 ,5,8,2,1,4,9,3},k=3Output:{4,9,3,8,5,8,2,1} Find the solution

A circle is a closed figure. All points on a circle are equidistant from a point inside the circle. The center point is called the center of the circle. The distance from a point to the center of a circle is called the radius. Area is a quantitative representation of the span of dimensions of a closed figure. The area of a circle is the area enclosed within the dimensions of the circle. The formula to calculate the area of a circle, Area=π*r*r To calculate the area, we give the radius of the circle as input, we will use the formula to calculate the area, algorithm STEP1: Takeradiusasinputfromtheuserusingstdinput.STEP2: Calculatetheareaofcircleusing, area=(

Challenges and Solutions of PHPHyperf Microservice Development Introduction: With the rapid development of the Internet and mobile Internet, microservice architecture has gradually become a hot spot for developers. As one of the most popular development languages, PHP has also ushered in the era of microservice architecture. In the field of PHP, the PHPHyperf framework can be said to be one of the most popular microservice frameworks currently. However, microservice development still faces some challenges in practice. This article will explore these challenges and propose corresponding solutions. 1. Challenge One: Distribution

In this article we will describe all possible ways to find quaternions, using A.P. for the first 3 terms and G.P. for the last 3 terms. First, we will explain the basic definitions of arithmetic progression (A.P.) and geometric progression (G.P.). Arithmetic Progression (A.P.) - It is a sequence of numbers in which the common difference (d) is the same or constant, meaning that the difference of two consecutive numbers is constant. For example: 1,3,5,7,9|d=2 Geometric Progression (G.P.) - This is a sequence of numbers where the common ratio (r) is the same, which means we can multiply the previous number with a fixed number. For example: 3, 6, 12, 24, ....|r=2 In this problem, we need to determine how many are in the array arr[] of N integers

In this article, we will use C++ to solve the problem of finding the number of subarrays whose maximum and minimum values are the same. The following is an example of the problem −Input:array={2,3,6,6,2,4,4,4}Output:12Explanation:{2},{3},{6},{6},{2 },{4},{4},{4},{6,6},{4,4},{4,4}and{4,4,4}arethesubarrayswhichcanbeformedwithmaximumandminimumelementsame.Input:array={3,3, 1,5,

In this problem, we are given a pointer to the head of the linked list and an integer k. In a group of size k, we need to reverse the linked list. For example -Input:1<->2<->3<->4<->5(doublylinkedlist),k=3Output:3<->2<->1<->5<->4 looking for solutions Method In this problem, we will formulate a recursive algorithm to solve this problem. In this method we will use recursion and solve the problem using recursion. Example#include<iostream&

There are many ways to install the win7 system. Many people will install the win7 system through the hard disk. The editor of this article will specifically introduce you to the one-click installation method, which is also the simplest method. Don’t miss it if you don’t know how. 1. First, we open the computer browser and search the official website of Magic Pig One-Click System Reinstallation, download it and open it. 2. After downloading, we open it and click online reinstallation. 3. Next, we will wait patiently for it to be installed. 4. The installation is complete. Next we need to click to restart the computer now. 5. After restarting the computer, we still need to return to the main interface to continue completing the installation. Then our installation is completed. After completing the above operations, we can complete the one-click installation of the win7 system. I hope it will be helpful to everyone.
