Search This Blog

Showing posts with label template. Show all posts
Showing posts with label template. Show all posts

Saturday, 1 January 2022

title: Swap using template

 title: Swap using template

program:

#include<iostream>

using namespace std;

template<class T>

void swapme(T & x, T & y)

{

T temp = x;

x=y;

y=temp;

}

int main()

{

int a,b;

cout<<"Enter the two integer values : ";

cin>>a>>b;

swapme(a,b);

cout<<"After Sapping A ="<<a<<", B = "<<b<<endl;

double p,q;

cout<<"Enter the two double values :";

cin>>p>>q;

swapme(p,q);

cout<<"After the swapping : P ="<<p<<" , Q = "<<q<<endl;

return 0;

}

OUPUT







Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts