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; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Great service! I had an assignment theory to be done and wasn't specific enough from my side on what I exactly needed it for. Even after messaging the expert one day before, they had it done the next day by the time I requested last minute.
Comments
Leave a comment