Division

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

6 comments:

  1. Take 3 inputs
    float a,b,c;
    cin>>a>>b;
    c=displayresult(a,b)
    cout<<a<<endl<<b<<endl<<c;

    ReplyDelete
  2. 1.Remove the space in third line after template and before <.
    2.Remove the space in fourth line after , and before T n2.
    works 100%

    ReplyDelete
  3. #include
    using namespace std;
    template
    T displayresult(T n1, T n2)
    {
    return n1/n2;
    }
    int main() {
    float a,b;
    cin>>a>>b;
    cout<<a<<endl<<b<<endl<<displayresult(a,b);
    return 0;
    }

    ReplyDelete
  4. template largest num ans:

    #include
    using namespace std;
    template
    T Large(T n1,T n2)
    {
    if(n1>n2)
    {cout<>a>>b>>c>>d;
    Large(a,b);
    cout<<"\n";
    Large(c,d);
    return 0;
    }

    ReplyDelete