Write a program to exchange values of two variables

Write a program to exchange values of two variables
class test
{
Public static void main(String args[])
{
int x=10,y=20,z;
x=y;
y=z;
z=x;
System.out.println(“After exchange values of x is ”+x+ “and y is ”+y);
}
}

Output:
After exchange values of x is 20and y is 10

Leave a Reply

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