Java Program Swap Two Number With Third Variable

      No Comments on Java Program Swap Two Number With Third Variable
class scan
{
 public static void main(String arg[])
   {
     int x,y,z;
   x=5;
   y=10;
 System.out.println("Value of x before swaping:- "+x);
 System.out.println("Value of y before swaping:- "+y); 

z=x;
x=y;
y=z;

System.out.println("Value of x after swaping:- "+x);
System.out.println("Value of y after swaping:- "+y);
   }
}

OUTPUT:-

Value of x before swaping:- 5
Value of y before swaping:- 10
Value of x after swaping:- 10
Value of y after swaping:- 5

Leave a Reply

Your email address will not be published. Required fields are marked *