Find Maximum of two integers, two float and two characters using function template
Runtime Input :
4.2
2.4
4.2
5
8
5
8
Z
A
Z
A
#include <iostream>
template<class T>
T Max(T a, T b) {
return a > b? a : b;
}
int main() {
float fa, fb;
int ia, ib;
char ca, cb;
std::cin >> fa >> fb;
std::cout << Max(fa, fb) << '\n';
std::cin >> ia >> ib;
std::cout << Max(ia, ib) << '\n';
std::cin >> ca >> cb;
std::cout << Max(ca, cb) << '\n';
return 0;
}
Comments
Leave a comment