Table of Contents
Basic properties of the arithmetic mean
Arithmetic mean formula
Example
Home Backend Development C++ In C programming, arithmetic mean

In C programming, arithmetic mean

Sep 17, 2023 am 11:41 AM
Keyword extraction: c programming arithmetic arithmetic mean

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;
}
Copy after login

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

, X

2, X3

, X

4

……X

n is the arithmetic mean between N two given numbers X and Y.

Then X, X

1, 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.
Copy after login

Therefore the tolerance d is given by.

22 24 26 28 30 32 34
Copy after login
We have the value of A and the value of the tolerance (d), now we can find all N arithmetic means between X and Y. Example
Y = X + (N + 2 - 1)d
Y - X = (N + 1)d
Copy after login
Output
d = (Y - X) / (N + 1)
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
Use C++ to write code to find the Nth non-square number Use C++ to write code to find the Nth non-square number Aug 30, 2023 pm 10:41 PM

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,

Inversion algorithm for right rotation of array written in C++ Inversion algorithm for right rotation of array written in C++ Sep 08, 2023 pm 08:17 PM

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

In C programming, find the area of ​​a circle In C programming, find the area of ​​a circle Aug 25, 2023 pm 10:57 PM

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 for PHP Hyperf microservice development Challenges and solutions for PHP Hyperf microservice development Sep 12, 2023 am 08:25 AM

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

Written in C++, find the number of quadruples whose first three terms are arithmetic sequences and the last three terms are geometric sequences. Written in C++, find the number of quadruples whose first three terms are arithmetic sequences and the last three terms are geometric sequences. Aug 30, 2023 pm 02:09 PM

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

Write a code using C++ to find the number of subarrays with the same minimum and maximum values Write a code using C++ to find the number of subarrays with the same minimum and maximum values Aug 25, 2023 pm 11:33 PM

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,

Reverse doubly linked list grouping by given size using C++ Reverse doubly linked list grouping by given size using C++ Sep 04, 2023 am 09:49 AM

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&

Specific steps to install win7 system on computer with one click Specific steps to install win7 system on computer with one click Jul 20, 2023 pm 05:21 PM

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.

See all articles