Header Ads Widget

Write a python program to swap two numbers without using third variable.

 Program:-

a=int(input("a="))
b=int(input("b="))
print("Values before swapping\n","a=",a,"b=",b)
a=a+b
b=a-b
a=a-b
print("Values after swapping\n","a=",a,"b=",b)

Output:-

a=2
b=3
Values before swapping
a= 2 b= 3
Values after swapping
a= 3 b= 2



Post a Comment

0 Comments