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.
1
Expert's answer
2013-01-09T08:25:03-0500
#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;
Comments
Leave a comment