find the average of 10 numbers to an array using function .the array should be controlled by while loop?
Code:
#include <iostream.h>
float sum(float x[],int size);
main()
{
float a[10];
int n=10;
while (n<10)
{
cin>>a[n];
n++;
}
cout<<"avg = "sum (a+n)/n;
}
floatsum(floatx{},int size)
{
float total=o;
for(int i=0,i<size,i++);
{
total=total +x[i];
}
return total;
}
Comment