-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswapping.py
36 lines (36 loc) · 855 Bytes
/
swapping.py
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
#swapping using third variable
A=int(input("Enter 1 st number:"))
B=int(input("Enter 2 nd number:"))
print("befpore swapping",A,B)
temp=A
A=B
B=temp
print("after swapping",A,B)
#swapping using arithmetic operators
X=int(input("Enter 1 st number:"))
Y=int(input("Enter 2nd number:"))
print("before swapping",X,Y)
(X,Y)=(Y,X)
print("after swapping",X,Y)
W=int(input("Enter 1st number:"))
D=int(input("Enter 2nd number:"))
print("before swapping",W,D)
W=W-D
D=W+D
W=D-W
print("after swapping",W,D)
P=int(input("Enter 1st nmber:"))
Q=int(input("Enter 2nd number:"))
print("before swapping",P,Q)
P=P*Q
Q=P/Q
P=P/Q
print("after swapping",P,Q)
#swapping using bitwise operator(XOR)
E=int(input("Enter 1st number:"))
F=int(input("Enter 2nd number:"))
print("before swapping",E,F)
F=E^F
E=E^F
F=E^F
print("after swapping",E,F)