(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
```

Computer Science & Information Technology

You might also like to view...

What are predefined computations that perform complex calculations?

A) Formulas B) Functions C) Expressions D) Arguments

Computer Science & Information Technology

For security control, a SkyDrive requires a:

A) Microsoft Account. B) Windows Live Drive. C) Windows Live Cloud. D) Windows Live ID.

Computer Science & Information Technology

A line chart is used to display a percent to a whole

Indicate whether the statement is true or false

Computer Science & Information Technology

Items are considered old only after a certain number of days that you specify.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology