Saturday, 9 March 2019

CPP-EX23


 Write a C++ program to find maximum of two integer numbers and two  float numbers by using function template.

#include<iostream.h>
#include<conio.h>

template<class T>

 T big(T a,T b)
   {
    if(a>b)
    return(a);
    else
    return(b);
   }

int main()
   {
    int num1,num2;
    float n1,n2;
    clrscr();
    cout<<"\n\n*********** Enter Data ***********";
    cout<<"\nEnter the two integer numbers:";
    cin>>num1>>num2;
  
 cout<<"\nEnter the two float numbers:";
    cin>>n1>>n2;
   
cout<<"\n*********** Finding Maximum ***********";
    cout<<"\nMaximum integer number is:"<<big(num1,num2);
    cout<<"\nMaximum of float numbers is:"<<big(n1,n2);
    getch();
    return 0;
   }