-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathC++ Call by reference.c
More file actions
55 lines (51 loc) · 941 Bytes
/
Copy pathC++ Call by reference.c
File metadata and controls
55 lines (51 loc) · 941 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
using namespace std;
//Initial Template for C++
#include <iostream>
using namespace std;
//Position this line where user code will be pasted.
int main()
{
int t;
cin>>t;
while(t--)
{
int a, b;
cin>>a>>b;
reverse_dig(a,b);
swap(a,b);
cout<<a<<" "<<b<<endl;
}
return 0;
}
/*Please note that it's Function problem i.e.
you need to write your solution in the form of Function(s) only.
Driver Code to call/invoke your function is mentioned above.*/
//User function Template for C++
void reverse_dig(int &a,int &b)
{
int x=a;
int y=b;
int num=0;
while(x)
{
int r=x%10;
num=num*10+r;
x/=10;
}
a=num;
num=0;
while(y)
{
int r=y%10;
num=num*10+r;
y/=10;
}
b=num;
}
void swap (int &a,int &b)
{
a=a+b;
b=a-b;
a=a-b;
}