HomeArray

How To Calculate The Average of all the values in the Array C++ Program

How To Calculate The Average of all the values in the Array C++ Program
Like Tweet Pin it Share Share Email

Hi,Today we make a program How to calculate the average of all the values in the array.in This program we Show That user enter Value and Average Values Show.

Also don’t miss some of the other Code : 

#How To Fill The Array of Five Elements in C++ Program

#How To Fill and Display Array Using Functions C++

#How To Display Data Type of int, float, double and char Size using C++ Program

#How To Calculate The Average Maximum and Minimum Temperature of 7 Days using Array in C++

#How To Calculate The Sum of All Values in An Array C++ Program

Calculate The Average of all the values in the Array C++

#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
int n, i;
float num[100], sum=0.0, average;
cout << "Enter the numbers of data: ";
cin >> n;
while (n > 100 || n <= 0)
{
cout << "Error! number should in range of (1 to 100)." << endl;
cout << "Enter the number again: ";
cin >> n;
}
for(i = 0; i < n; ++i)
{
cout << i + 1 << ". Enter number: ";
cin >> num[i];
sum += num[i];
}
average = sum / n;
cout << "Average = " << average;
return 0;
}

#How To Make Multiplication Table Of a Given Number Using while Loop in C++ Program
Output of ProgramCalculate The Average of all the values in the Array C++

Read More :-

#How To Find the Factorial of a Number using while loop in C++ Program

#How To Convert Miles into kilometer using in C++ Program

#How To Make A Biodata Using in C++ Program

#How To Check the Character is vowel or Consonant in C++ Program

#How To Find The Factorial of a Number using C++ Program

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *