import java.util.Scanner;
public class Swappingwithout {
public static void main(String[] args)
{
Scanner Sc=new Scanner(System.in);
int X,Y;
System.out.println("Please enter the value of X");
X=Sc.nextInt();
System.out.println("The value of X is:"+X);
System.out.println("Please enter the value of Y");
Y=Sc.nextInt();
System.out.println("The value of Y is:"+Y);
// logic Starts
Y=X+Y;
X=Y-X;
System.out.println("After Swapping the value of X is:"+X);
Y=Y-X;
System.out.println("After Swapping the value of Y is:"+Y);
}
}
public class Swappingwithout {
public static void main(String[] args)
{
Scanner Sc=new Scanner(System.in);
int X,Y;
System.out.println("Please enter the value of X");
X=Sc.nextInt();
System.out.println("The value of X is:"+X);
System.out.println("Please enter the value of Y");
Y=Sc.nextInt();
System.out.println("The value of Y is:"+Y);
// logic Starts
Y=X+Y;
X=Y-X;
System.out.println("After Swapping the value of X is:"+X);
Y=Y-X;
System.out.println("After Swapping the value of Y is:"+Y);
}
}
No comments:
Post a Comment