Code to calculate the average in C++ using recursion