employer cover photo
employer logo

Question d’entretien chez Nuance

Swap two numbers without using third variable

Réponse à la question d'entretien

Utilisateur anonyme

7 avr. 2017

int x = 10; int y = 20; System.out.println("Before swap:"); System.out.println("x value: "+x); System.out.println("y value: "+y); x = x+y; y=x-y; x=x-y; System.out.println("After swap:"); System.out.println("x value: "+x); System.out.println("y value: "+y);

1