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"; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment