Computer Science, asked by yajatbisht51, 11 months ago

write a program in python to print the value of two integer before and after swapping,without using third variable​

Answers

Answered by aryanacc28
2

Answer:

x = 10

y = 5

   

# Code to swap 'x' and 'y'  

 

# x now becomes 15  

x = x + y    

 

# y becomes 10  

y = x - y  

 

# x becomes 5  

x = x - y    

print("After Swapping: x =", x, " y =", y)

Explanation:

Answered by Equestriadash
12

The following codes must be typed in script mode, saved and then executed.

CODE:

a = input("Enter a value:")

b = input("Enter a value:")

print("The value of a is", a)

print("The value of b is", b)

a, b = b, a

print("The values after swapping are:")

print("a =", a)

print("b =", b)

OUTPUT:

Attachments:
Similar questions