0% found this document useful (0 votes)
46 views1 page

6 +Average+of+Numbers

This C++ program takes user input of multiple numbers, adds them together, and calculates the average. The user first enters the number of elements to provide as input. The program then prompts the user to input each number, adds it to the running sum, and after all numbers are entered it divides the total sum by the original number of elements to calculate the average.

Uploaded by

aleksandar7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views1 page

6 +Average+of+Numbers

This C++ program takes user input of multiple numbers, adds them together, and calculates the average. The user first enters the number of elements to provide as input. The program then prompts the user to input each number, adds it to the running sum, and after all numbers are entered it divides the total sum by the original number of elements to calculate the average.

Uploaded by

aleksandar7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Program to Find Average of Numbers

#include <iostream>
using namespace std;

int main()
{
int n, i;
float num[100], sum=0.0, average;

cout << "Enter the numbers of elements: ";


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;
}

You might also like