Suppose, for the sake of illustration, that you have a version of
analyze_trades
that uses two subfunctions, mean_price
and
mean_size
:
double mean_price (struct trade **array, int length) { int counter; double sum = 0.0; for (counter = 0; counter < length; ++counter) sum = sum + array[counter] -> price; return sum / counter; } double mean_size (struct trade **array, int length) { int counter; double sum = 0.0; for (counter = 0; counter < length; ++counter) sum = sum + array[counter] -> number; return sum / counter; }