Dados dos números x e y, necesitamos intercambiar sus valores
Ejemplos:
Input : x = 10, y = 20; Output : x = 20, y = 10 Input : x = 200, y = 100 Output : x = 100, y = 200
Java
// Java program to swap two variables public class GfG { public static void main(String[] args) { int x = 100, y = 200; System.out.println("Before Swap"); System.out.println("x = " + x); System.out.println("y = " + y); int temp = x; x = y; y = temp; System.out.println("After swap"); System.out.println("x = " + x); System.out.println("y = " + y); } }