Write a C++ program to find maximum of two integer numbers and two float numbers by using function template.
//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<conio.h>
#include<iostream.h>
template <typename x> //template
x big (x a,x b)
{
if(a>b)
{
return(a);
}
else
return(b);
}
int main()
{
int a,b,x,y;
cout<<"\nEnter 1st integer number : ";
cin>>a;
cout<<"\nEnter 2nd integer number : ";
cin>>b;
cout<<"\nEnter 1st float number : ";
cin>>x;
cout<<"\nEnter 2nd float number : ";
cin>>y;
cout<<"Maximum integer number is : "<<big<int>(a,b)<<endl;
cout<<"Maximum float number is : "<<big<float>(x,y);
getch();
return(0);
}
0 Comments