Nokia Interview Question

You have x and y variables. Swap the values without using a 3rd variable.

Interview Answers

Anonymous

Mar 20, 2017

xor

2

Anonymous

Jun 15, 2017

x=5; y=2; x=x+y; //x=5+2=7 x=7 y=x-y; //y=7-2=5 y=5 x=x-y;//x=7-5=2 x=2

2

Anonymous

Sep 13, 2016

Algebra