Friday, 26 January 2018

WAP to swap the numbers using the concept of function template. C++ GTU

#include<iostream>
using namespace std;
template <class T>
void swap1(T &a,T &b)
{
    T temp;
    temp=a;
    a=b;
    b=temp;
}
main()
{
    int a,b;
    float x,y;
    cout<<"ENTER TWO INT NUMBER :";
    cin>>a>>b;
    swap1(a,b);
    cout<<"NUMBERS AFTER SWAP:"<<a<<" "<<b<<endl;
    cout<<"ENTER TWO FLOAT NUMBER :";
    cin>>x>>y;
    swap1(x,y);
    cout<<"NUMBERS AFTER SWAP:"<<x<<" "<<y;
}

No comments:

Post a Comment

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...