Code is copied!
Program to input two variables and swap them without using third variable JAVA
Write a Program to input two variables and swap them without using third variable.
import java.util.*; class swap { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println("Before Swapping: " + " " +"a =" + a + " b = " + b); a = a+ b; b = a - b; a = a- b; System.out.println("a = " + a + ", b = " + b); } }