wap to swapping of two numbers using third variable
//wap to swapping of two numbers
import java.util.Scanner;
class swapping
{
public static void main(String[] arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter First Number : ");
int x=sc.nextInt();
System.out.println("Enter second number : ");
int y=sc.nextInt();
System.out.println("Before Swapping x ="+x +" y="+y);
x=x+y;
y=x-y;
x=x-y;
System.out.println("After Swapping x ="+x +" y="+y);
}
}
Comments
Post a Comment