(Function Template minimum) Write a program that uses a function template called minimum to determine the smaller of two arguments. Test the program using integer, character and floating- point number arguments.
What will be an ideal response?
```
// Finding the minimum using a function template.
#include
using namespace std;
// definition of function template minimum; finds the smaller of 2 values
template < class T >
T minimum( T value1, T value2 )
{
if ( value1 < value2 )
return value1;
else
return value2;
} // end function template minimum
int main()
{
// demonstrate minimum with int valuesint int1; // first int value
int int2; // second int value
cout << "Input two integer values: ";
cin >> int1 >> int2;
// invoke int version of minimum
cout << "The smaller integer value is: " << minimum( int1, int2 );
// demonstrate minimum with char values
char char1; // first char value
char char2; // second char value
cout << "\n\nInput two characters: ";
cin >> char1 >> char2;
// invoke char version of minimum
cout << "The smaller character value is: " << minimum( char1, char2 );
// demonstrate minimum with double values
double double1; // first double value
double double2; // second double value
cout << "\n\nInput two double values: ";
cin >> double1 >> double2;
// invoke double version of minimum
cout << "The smaller double value is: " << minimum( double1, double2 )
<< endl;
} // end main
```
You might also like to view...
Give a set of functional dependencies for the relational schema R(A, B, C, D) with primary key AB under which R is in 1NF but not in 2NF.
What will be an ideal response?
What are the general steps for taking a snapshot?
What will be an ideal response?