Whats up guys, just got a simple averaging program here. I can't seem to figure out how to have the 5 numbers averaged out. I got the for-loop working fine for the 5 counts since I need 5 numbers to be averaged but I just can't seem to figure out how to store the numbers and then have them averaged out. This is what I have so far.
//AverageProgram.cpp
//##
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main(){
intconst SIZE=5;
double setOfNumbers[SIZE]={};
double average;
double sum=0;
cout<<"Enter "<<SIZE<<" numbers."<<endl;
for(int i=0;i<SIZE;i++){
cout<<"Enter number #"<<i+1<<">>";
cin>>setOfNumbers[i];
sum+=setOfNumbers[i];
}//end for
average=sum/SIZE;
cout<<"\n\nNumbers entered "<<endl;
for(int i=0;i<SIZE;i++){
cout<<"Number #"<<i+1<<' '<<setOfNumbers[i]<<'\n';
}//end for
cout<<"\nSum: "<<sum<<endl;
cout<<"Average: "<<average<<endl;
return 0; //indicates success
Enter 5 numbers.
Enter number #1>>6
Enter number #2>>3
Enter number #3>>2
Enter number #4>>27
Enter number #5>>18
Numbers entered
Number #1 6
Number #2 3
Number #3 2
Number #4 27
Number #5 18
Sum: 56
Average: 11.2