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
1
Expert's answer
2012-08-21T10:11:55-0400
#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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS