1// If two characters are passed to function template, character with larger ASCII value is displayed.
2
3#include <iostream>
4using namespace std;
5
6// template function
7template <typename T>
8T Large(T n1, T n2)
9{
10 return (n1 > n2) ? n1 : n2;
11}
12
13int main()
14{
15 int i1, i2;
16 float f1, f2;
17 char c1, c2;
18
19 cout << "Enter two integers:\n";
20 cin >> i1 >> i2;
21 cout << Large(i1, i2) <<" is larger." << endl;
22
23 cout << "\nEnter two floating-point numbers:\n";
24 cin >> f1 >> f2;
25 cout << Large(f1, f2) <<" is larger." << endl;
26
27 cout << "\nEnter two characters:\n";
28 cin >> c1 >> c2;
29 cout << Large(c1, c2) << " has larger ASCII value.";
30
31 return 0;
32}