Largest Number

#include <iostream>
using namespace std;
template <class T>
  float Large(T n1, T n2)
{
  return (n1 > n2) ? n1 : n2;
}
int main() {
int a,b;
  float c,d;
  cin>>a>>b>>c>>d;
  cout<<Large(a,b)<<endl<<Large(c,d);
return 0;
}

8 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. /* works 100% just make the changes I've given in front of lines
    as comments blogspot keeps cutting < brackets off. */

    #include < iostream > //dont give space before and after iostream
    using namespace std;

    template< class T > //dont give space before and after class T

    class largestno
    {
    public:
    T Large(T n1,T n2)
    {
    return (n1 > n2) ? n1 : n2;
    }
    };
    int main() {

    largestno < int > t; //dont give space before and after int
    largestno < float > u; //dont give space before and after float
    int a,b;
    float c,d;
    cin>>a>>b>>c>>d;
    cout<<t.Large(a,b)<<endl<<u.Large(c,d);
    return 0;
    }

    ReplyDelete
  5. #include
    using namespace std;
    template
    float Large(T n1,T n2)
    {
    return (n1 > n2) ? n1 : n2;
    }
    int main() {
    int a,b;
    float c,d;
    cin>>a>>b>>c>>d;
    cout<<Large(a,b)<<endl<<Large(c,d);
    return 0;
    }

    ReplyDelete