# 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;

}

## Comments

## Leave a comment