How to swap two numbers without using a temporary variable ? | Function to swap the numbers ; Same as a = a + b ; Same as b = a - b ; Same as a = a - b ; Driver code ; Function call
def swap ( a , b ) : NEW_LINE INDENT a = ( a & b ) + ( a b ) NEW_LINE b = a + ( ~ b ) + 1 NEW_LINE a = a + ( ~ b ) + 1 NEW_LINE print ( " After ▁ Swapping : ▁ a ▁ = ▁ " , a , " , ▁ b ▁ = ▁ " , b ) NEW_LINE DEDENT a = 5 NEW_LINE b = 10 NEW_LINE swap ( a , b ) NEW_LINE