Question: Write two regular c-type function templates called returnMinimum and returnMaximum that returns the smaller or the larger of two input arguments. In the main, demonstrate

Write two regular c-type function templates called returnMinimum and returnMaximum that returns the smaller or the larger of two input arguments.

In the main, demonstrate the usage of both functions on data types int, double, char, and string. No user input.

//C++ keep it at only these two libaries cmath if needed

#include #include

using namespace std;

template void returnMinimum(T* arr, int);

template void returnMaximum(T* arr, int);

int main() {

int size = 4;

double arrDoub[] = { 5.56,6.67,7.23,8.45 }; char arrChar[] = { '3','8','2','5' }; int arrInt[] = { 4,2,3,1 };

returnMinimum(arrDoub, size); returnMinimum(arrChar, size); returnMinimum(arrInt, size);

returnMaximum(arrDoub, size); returnMaximum(arrChar, size); returnMaximum(arrInt, size); return 0;

}

template void returnMinimum(T* arr, int size) {

cout << endl; int min = arr[0];

for (int i = 1; i < size; i++) { if (size[i] > min) { min = size[i]; }

cout << min << endl; } return min;

};

template void returnMaximum(T* arr, int size) { int max = arr[0];

for (int i = 1; i < size; i++) { if ( size[i] > max) { max = size[i]; } cout << max << endl; } return max; };

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!