c++ programming- Tryin to get a number within an array that is twice the average
- by max
i have been assigned to set up an array with points. I am told to get the maximum value, average, nd within this same array, if any point in the array is twice the average, i should cout an "outlier." So far i have gotten the average and maximum numbers in the array. but i am unable to set the programme to cout the outlier. Instead it gives me a multiple of the average. pls help!
here is the programme;
int main()
{
const int max = 10;
int ary[max]={4, 32, 9, 7, 14, 12, 13, 17, 19, 18};
int i,maxv;
double out,sum=0;
double av;
maxv= ary[0];
for(i=0; i
}
cout<<"maximum value: "<
for(i=0; i
sum = sum + ary[i];
av = sum / max;
}
cout<<"average: "<
out = av * 2;
if(ary[i]out)
{
cout<<"outlier: "<
return 0;
}