64 752
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #13090 in C++ for rochielle quita

Question #13090
problem:
write a program that reads in a list of integer values , entered one per line, and outputs the average of the integer 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 <iostream.h>

int i, num, arr[100], *a;
double avg=0;

void main(){
a=arr;
cout<<"how many numbers will be on the list? ";
cin>>num;
cout<<"enter "<<num<<" numbers, please:\n";
for(i=0;i<num;i++) { cin>>*a; a++; }
for(i=0;i<num;i++) avg+=arr[i];
avg = avg/num;
cout<<"the average is "<<avg<<"\n";
}

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