File tree 1 file changed +3
-28
lines changed
1 file changed +3
-28
lines changed Original file line number Diff line number Diff line change 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
-
9
1
A = 20
10
-
11
2
B = 45
12
-
13
3
print ("Before Swap Value of A is = " , A )
14
4
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
25
8
print ("After Swap Value of A is = " , A )
26
9
print ("After Swap Value of B is = " , B )
27
-
28
-
29
-
30
10
C = 80
31
-
32
11
D = 75
33
-
34
12
print ("Before Swap Value of C is = " , C )
35
13
print ("Before Swap Value of D is = " , D )
36
-
37
14
C , D = 75 , 80
38
-
39
-
40
15
print ("After Swap Value of C is = " , C )
41
16
print ("After Swap Value of D is = " , D )
You can’t perform that action at this time.
0 commit comments