Question d’entretien chez Broadcom

How to swap the values in 2 variables without using a temporary variable.

Réponses aux questions d'entretien

Utilisateur anonyme

17 mars 2010

a=a^b b=b^a a=a^b

12

Utilisateur anonyme

10 juill. 2011

but it should say swap two integers! because this XOR won't work with float for example

4

Utilisateur anonyme

15 juill. 2011

This works for floats: a = a+b b = a-b a = a-b But you might overflow on a+b.

5

Utilisateur anonyme

12 déc. 2014

push and pop the values from the stack.

2

Utilisateur anonyme

23 juill. 2017

While using the XOR method, add condition to check if numbers are same. If they are same, XOR results in 0.