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


Answer: -


a = int(input('Enter First Number:- '))
b = int(input('Enter Second Number:- '))
a, b = b, a
print('New value of Variable a is :- ', a)
print('New value of Variable b is :- ', b)


Output: -

Enter First Number:- 5
Enter Second Number:- 6
New value of Variable a is :-  6
New value of Variable b is :-  5

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post