-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path208.cpp
More file actions
39 lines (26 loc) · 762 Bytes
/
208.cpp
File metadata and controls
39 lines (26 loc) · 762 Bytes
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
//call By Reference
#include<iostream>
using namespace std;
template<class T>
void SwapR(T &p,T &q)
{
T temp = p;
p = q;
q = temp;
}
int main()
{
int iNo1 = 11,iNo2 = 21;
cout<<"Before swap data is: "<<iNo1<<" "<<iNo2<<endl;
SwapR(iNo1,iNo2);
cout<<"After swap data is: "<<iNo1<<" "<<iNo2<<endl;
float fNo1 = 11.0,fNo2 = 21.0;
cout<<"Before swap data is: "<<fNo1<<" "<<fNo2<<endl;
SwapR(fNo1,fNo2);
cout<<"After swap data is: "<<fNo1<<" "<<fNo2<<endl;
char cNo1 = 'A',cNo2 = 'B';
cout<<"Before swap data is: "<<cNo1<<" "<<cNo2<<endl;
SwapR(cNo1,cNo2);
cout<<"After swap data is: "<<cNo1<<" "<<cNo2<<endl;
return 0;
}