Answer to Question #13427 in C++ for Darryl kaye

Question #13427
write a program that reads in a list of integer values, entered one per line, and outputs the averege of the integers entered. The program asks the user how many numbers will be on the list and uses this value to control the loop that reads in the numbers. This program need not echo the input.
1
Expert's answer
2012-08-21T10:45:38-0400

#include<conio.h>
#include <iostream>
using namespace std;
int main()
{
int n;
int arrayofintegervalue[1000];
cout<<"How many numbers will be on the list?: ";
cin>>n;
for(int i=0;i<n;i++){
cout<<"Enter integer value "<<(i+1)<<":
";
cin>>arrayofintegervalue[i];
}
int sum=0;
double average=0;
for(int i=0;i<n;i++){
sum+=arrayofintegervalue[i];
}
average=sum/n;
cout<<"Average = "<<average;
cout<<"
Press any key to exit";
getch();
return 0;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS