Cisco interview question

Swap two integers without using additional variable.

Interview Answers

Anonymous

Apr 18, 2019

x = 2 y = 5 y = x+y x = y - x y = y - x or y = x*y x= y // x y = y// x or y = x ^ y x = x ^y y = x ^ y

Anonymous

Sep 30, 2015

a=5 b=4 a=5+4 or 9 b=4 a=b or 4 b=a-b or 5