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
using namespace std;
template
template
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
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
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
Get step-by-step solutions from verified subject matter experts
