Trying to get a number within an array that is twice the average 
<p>I have been  assigned to set up an array with points. I am told to get the  maximum value,  average, and within this same array, if any point in the array is twice the average, I should <code>cout</code> an "outlier." So far I have  gotten the average and maximum numbers in the array. but i am unable to set the programme to <code>cout</code> the outlier. Instead it gives me  a multiple of the average.
here is the programme;</p>

<pre><code>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&lt;max; i++)
    {
        if(maxv&lt;ary[i])
            maxv= ary[i];

    }
    cout&lt;&lt;"maximum value: "&lt;&lt;maxv&lt;&lt;endl;

    for(i=0; i&lt;max; i++)
    {

        sum = sum + ary[i];
        av = sum / max;
    }
    cout&lt;&lt;"average: "&lt;&lt;av&lt;&lt;endl;

    out = av * 2;

    if(ary[i]&gt;out)
    {
        cout&lt;&lt;"outlier:  "&lt;&lt;maxv&lt;&lt;endl;
    }
    else
    {
        cout&lt;&lt;"ok"&lt;&lt;endl;
    }


    return 0;
}
</code></pre>
