60 594
Assignments Done
97,9%
Successfully Done
In April 2018

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.
Expert's answer

#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions