02 Dec 2020
Rewrite the following function so that it can operate on arrays of any data type, not just integers. You may assume that all operations and comparisons are defined for all data types that we would pass into this function:
int cloneArrayReturnMax(int* arr1, int size1, int* arr2, int size2) { _x000D_ int end = size1; _x000D_ if (end > size2) _x000D_ end = size2; _x000D_ for (int i = 0; i < end; i++) _x000D_ arr1[i] = arr2[i];_x000D_ int max = arr1[size1 - 1];_x000D_ for (int i = size1 - 2; i >= 0; i--)_x000D_ if (max < arr1[i]) _x000D_ max = arr1[i];_x000D_ return max; }