cpp program to find average of n numbers

Solutions on MaxInterview for cpp program to find average of n numbers by the best coders in the world

showing results for - "cpp program to find average of n numbers"
Federica
05 Jan 2021
1#include <iostream>
2using namespace std;
3
4int main() {
5    
6    // initialize an array without specifying size
7    double numbers[] = {7, 5, 6, 12, 35, 27};
8
9    double sum = 0;
10    double count = 0;
11    double average;
12
13    cout << "The numbers are: ";
14
15    //  print array elements
16    // use of range-based for loop
17    for (const double &n : numbers) {
18        cout << n << "  ";
19
20        //  calculate the sum
21        sum += n;
22
23        // count the no. of array elements
24        ++count;
25    }
26
27    // print the sum
28    cout << "\nTheir Sum = " << sum << endl;
29
30    // find the average
31    average = sum / count;
32    cout << "Their Average = " << average << endl;
33
34    return 0;
35}
queries leading to this page
calculate the average of numbers c 2b 2b geeksforgeeksc 2b 2b program to find average of n numbers using while loopfind out out average array c 2b 2btake the matrix calculate its average and tell how many numbers are higher than avg c 2b 2bc 2b 2b calculate averageaverage of n numbers in c 2b 2bfind the average of n numbers c 2b 2bc 2b 2b find averagebasic average c 2b 2baverage code foe c 2b 2bcalculate the average of array elementsc 2b 2b program to find average of array elementsfind the average of 10 numbers entered in an array the array should be controlled by while loop average c 2b 2bhow to find the mean of an array in c 2b 2barray programs in c 2b 2bcalculate average for loop c 2b 2bbest way to store an average in c 2b 2bcpp array programsc 2b 2b program to calculate average using arrayc 2b 2b program for array operationsarray basic programs in c 2b 2baverage of numbers c 2b 2bc 2b 2b program to find the average of 3 numbershow to find average of n numbers in c 2b 2bwrite a c 2b 2b program to read a set of numbers in an array 26 to find sum and average of them 3ed 09take two int values from user 2c print smallest among them and average of them c 2b 2bmean of array in c 2b 2bfind average of n numbers c 2b 2bgiven an array of integers and it e2 80 99s average 28i e mean you can read in the array and it e2 80 99s average 29 e2 80 93 draw a flowchart that illustrates an algorithm for calculating the standard deviation of the array elements average of array c 2b 2baverage calculator c 2b 2baverage elements of array c 2b 2bwrite a c 2b 2b program and display average numberfind the average of an array c 2b 2baverage of n numbers in c 2bc 2b 2b program to find the average of 10 numbersfind the average of numbers in c 2b 2baverage of numbers c 2b 2b using loopsc 2b 2b array program examplescpp array examplec 2b 2b program to find average of n numbers using for loopc 2b 2b average of an arrayc 2b 2b program to calculate average of numbers average of numbers cppc 2b 2b find average of arrayc 2b 2b program to find the average using functionswrite a c 2b 2b program to create a class which creates an integer array at run time 2c sorts given integer and displays the array value with their average c 2b 2b do the average of intcalculate mean in c 2b 2bcalculate average time in c 2b 2baverage numbers c 2b 2bhow to program to find the average of many numbers c 2b 2bwrite a program that generate 20 random numbers and save them in an array 2c after that find the highest number 2c lowest number and average from array c 2b 2b ask user for 10 numbers and storing them inside of an array 2c then display the smallest 2c largest 2c average 2c positive 2c negative numbersdisplay avg valuein array in c 2b 2baverage in c 2b 2bc 2b 2b program for finding average of n numbersc 2b 2b array programswrite a program that prompts the user for 10 doubles 2c stores them in an array 2c and displays their sum and average c 2b 2b output averagefind average in c 2b 2bgetting the average of onethusend numbers in c 2b 2bc 2b 2b how to output the mean of an arraycpp program to find average of n numbers