-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path20.cpp
40 lines (32 loc) · 780 Bytes
/
20.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//WAP to implement template class using function.
#include<iostream>
//using namespace std;
using std::cout;
using std::cin;
template<class No>
void swap(No &x, No &y)
{
No temp = x;
x = y;
y = temp;
}
void fun(int a, int b, float c, float d)
{
cout << "\nA and B Before Swapping: " << a << "\t" << b;
swap(a,b);
cout << "\nA and B After Swapping: " << a << "\t" << b;
cout << "\n\nC and D Before Swapping: " << c << "\t" << d;
swap(c,d);
cout << "\nC and D After Swapping: " << c << "\t" << d;
}
int main()
{
int a,b;
float c,d;
cout << "Enter A,B Values(integer):\n";
cin >> a>>b;
cout << "\nEnter C,D Values(float):\n";
cin >> c>>d;
fun(a,b,c,d);
return 0;
}