it a an C++ and it need to accept an array as a parameter and loop though the array adding the array elements and return their sum divided by the number of elements used. Am confused on changed it to find the average added on with the highest and lowest number.
1 2 3 4 5 6 7 8 9 10
{
int i;
max = min = v[0];
for (i = 1; i < n; i++) ]
{
if (v[i] > max) max = v[i];
if (v[i] < min) min = v[i];
}
Ignoring your last statement:
Supposing you had a six element array int a[]={1,4,27,13,6 ,2};
You could use a for loop to print out the individual elements with say cout<<a[i]<<" "; in the body of the for loop.
If you had a statement also in this for loop body like sum+=a[1], sum when printed would = 53.
sum/number of element=average of array values= 8. How would you get a more accurate average?