Lab 9 - Template Functions

The purpose of this lab is to code template functions and specific-instance functions.

You will be coding three functions. One function will be purely a template function which calculates the average of an array of values. The other two functions, both called printArray, will print an array of values. One will be a specific-instance function to print out doubles with 3 decimal places of precision. The other will be a template function.

The function specifications are:

Use the following main() function to test your code:
int main()
{
  int iArr[] = {4, 7, 19, 71, 55};
  char cArr[] = {'a', 'y', '%', '!', 'T'};
  double dArr[] = {8.3, 7.2, 19.65, 2.5, 15.27};

  printArray(iArr, 5);
  cout << "The average is " << calcAverage(iArr, 5) << endl;

  printArray(dArr, 5);
  cout << "The average is " << calcAverage(dArr, 5) << endl;

  printArray(cArr, 5);

  return 0;
}
If you have done your functions correctly, the double array should print out with 3 decimal places of precision while the integer and character arrays will just print out with just spaces. Both calcAverage functions should calculate the average of the two numeric arrays using double division.

Email your completed code to me.