How do i find the average???? please help

#include <iostream>
using namespace std;
int main ()
int mn,mx;
const int Numb = 10;
int a[Numb]; //10 elements
cout<<"Enter 10 values:"; //prompts user for 10 values.
for(int i=0;i<10;i++)
cout<< "\nEnter value: ";
cin>> a[i]; // puts values in array

for(int i=1;i<10;i++)
else if(mx<a[i])
mx = a[i];

cout<<"Maximum number is: "<< mx << endl;
cout<<"Minimum number is: "<< mn << endl;

return 0;


Last edited on
The average between all of the numbers? Just create a little loop that adds up all the numbers in your array and divide them by 10 (the number of elements your averaging)
Tell me how you would find the average, if the numbers were written down on paper, instead of being "inside" a computer program?
for all the numbers. I tried creating the loop but it didnt work i used a for loop
I would add all of them and then divide by 10
int sum= 0;
for(int i = 0; i < 10; i++)
   sum += a[i];

std::cout << "Average is: " << (sum / 10);

This will give you a whole number average
Im getting a redicously big number.
Lets see your updated code, the above method should work.
actually now its at 40
the numbers i entered was 1,2,3,4,5,6,7,8,9,10
i wanna ask you, do you know the formula for finding the average of n numbers? do you know and understand what the meaning of "average"?
define a new value
int madd=0;

after the value is entered
madd=(madd+a[i]); // Add values entered

Show the results
cout<<"Average number is: " << madd/10 << endl;// Average values entered
Im getting a redicously big number.

Scorpic's code should work. Unless you copy-paste it in the wrong spot. Put it as is, before return 0;.
Topic archived. No new replies allowed.