employer cover photo
employer logo
employer logo

Tata Consultancy Services

Fait partie de Tata Group

Employeur impliqué

Question d’entretien chez Tata Consultancy Services

How will you swap two numbers without using a temp

Réponse à la question d'entretien

Utilisateur anonyme

1 mars 2013

int a = 5; int b = 10; a = a + b; // i.e. a = 5 + 10 = 15; b = a - b; // i.e. b = 15 - 10 = 5; a = a - b; // i.e. a = 15 - 5 = 10; Final Answer is a = 10 and b = 5.

1