67 172
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #21085 in C++ for Candice Battle

Question #21085
Input a list of positive numbers (terminated by 0) into an array, find the mean (average) of the numbers in the array, and output the result. Use a subprogram to input the numbers, a function to find the mean, and a subprogram to output the result.
Expert's answer

#include <iostream>
#include <conio.h>

using namespace std;


//main function
int main()
{
double number;
double arrayofnumber[1000];
cout<<"Enter number: ";
cin>>number;
int count=0;
while(number!=0){
cout<<"Enter number: ";
cin>>number;
arrayofnumber[count]=number;
count++;
}
double average=0;
double sum=0;
for(int i=0;i<count-1;i++){
sum+=arrayofnumber[i];
}
average=sum/(count-1);
cout<<"Result = "<<average;
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