Frage im Vorstellungsgespräch bei IBM

swap two numbers without using temporary variable

Antworten zu Vorstellungsgespräch

Anonym

15. Mai 2011

b=a+b; a=b-a; b=b-a;

Anonym

30. Mai 2011

Sagar's answer is decent, but there might be problems if they consider overflow. Better is using xor: b = a XOR b a = a XOR b b = a XOR b