Answer to Question #21656 in C++ for Roger

Question #21656
Put into Psuedocode: 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. ....I have tried to do this but I am lost.
Expert's answer
#include <iostream>
using namespace std;

double avarage(int a[],int n)
int s=0;

for(int i=0;i<n;i++)
& s+=a[i];

return (s/double(n-1));

int input(int a[])
int x=1,i=0;
while (x > 0) {
& cin >> x;
& a[i] = x;
& i++;
return i;

void output1(int a[], int n)
cout << avarage(a, n);
int main(int argc, const char * argv[])
int a[1000],n;

n = input(a);
output1(a, n);

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!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog