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