Skip to content

Commit f0142a7

Browse files
committed
sdnbfs
1 parent 939de8b commit f0142a7

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

swap2.py

+3-28
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,16 @@
1-
# Wap to Swap 2 Numbers without using Thired/Temp Variable
2-
3-
# Hardcoding: whenevr you give direct values to your variables
4-
# this process is called Hardcoding
5-
6-
# logic based Question
7-
8-
91
A = 20
10-
112
B = 45
12-
133
print("Before Swap Value of A is = ", A)
144
print("Before Swap Value of B is = ", B)
15-
16-
# logic For Swap 2 Values Without Temp
17-
18-
A = A + B # A = 20+45 => A = 65
19-
20-
B = A - B # B = 65-45 => B = 20
21-
22-
A = A - B # A = 65-20 => A = 45
23-
24-
5+
A = A + B
6+
B = A - B
7+
A = A - B
258
print("After Swap Value of A is = ", A)
269
print("After Swap Value of B is = ", B)
27-
28-
29-
3010
C = 80
31-
3211
D = 75
33-
3412
print("Before Swap Value of C is = ", C)
3513
print("Before Swap Value of D is = ", D)
36-
3714
C , D = 75 , 80
38-
39-
4015
print("After Swap Value of C is = ", C)
4116
print("After Swap Value of D is = ", D)

0 commit comments

Comments
 (0)