Function for calculating the mean of an array double[] using accumulate
It must be the most common function for what everyone has a code snippet somewhere, but I have actually spent no less than 1.5 hour searching for it on SO as well as on other C++ sites and have not found a solution. I would like to calculate the mean of a double array[] using a function . I would like to pass the array to the function as a reference . There are millions of examples where the mean is calculated in a main() loop, but what I am looking for is a function what I can put in an external file and use it any time later. So far, here is my latest version, what gives a compile error: