24
Jun

Swap without third variable

Question :

Swap two variables without using a third temporary variable

Program:

Explanation:
Here num1, num2 acts as a tuple. Since tuples are mutable, the above assignment works perfectly well

Output: