(Function Template maximum) Write a program that uses a function template called maximum to determine the larger of two arguments. Test the program using integer, character and floating- point number arguments.

What will be an ideal response?


```
// Finding the maximum using a function template.
#include
using namespace std;

// definition of function template maximum; finds the larger of 2 values
template < class T >
T maximum( T value1, T value2 )
{
if ( value1 > value2 )
return value1;
else
return value2;
} // end function template max

int main()
{
// demonstrate maximum with int values
int int1; // first int value
int int2; // second int value

cout << "Input two integer values: ";
cin >> int1 >> int2;

// invoke int version of maximum
cout << "The larger integer value is: " << maximum( int1, int2 );

// demonstrate maximum 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 maximum
cout << "The larger character value is: " << maximum( char1, char2 );

// demonstrate maximum 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 maximum
cout << "The larger double value is: " << maximum( double1, double2 )
<< endl;
} // end main
```

Computer Science & Information Technology

You might also like to view...

The agile development process has five distinct stages:

What will be an ideal response?

Computer Science & Information Technology

How do you remove shape hints?

What will be an ideal response?

Computer Science & Information Technology

True or false: The Scene Gizmo is used to determine the camera's direction in relation to the 3D world

Indicate whether the statement is true or false

Computer Science & Information Technology

What component of UEFI helps to prevent malware from hijacking a system during or before the operating system load?

A. Execute Disable Bit B. Secure Boot C. UEFI Defender D. BitLocker

Computer Science & Information Technology