// this program swaps the values of two variables a and b without using any third variable
public class swap
{
public static void main(String[] args)
{
int a,b;
a=5;
b=3;
a=a+b;
b=a-b;
a=a-b;
System.out.print("a = "+a);
System.out.println("b = "+b);
}
}
public class swap
{
public static void main(String[] args)
{
int a,b;
a=5;
b=3;
a=a+b;
b=a-b;
a=a-b;
System.out.print("a = "+a);
System.out.println("b = "+b);
}
}
output:
a=3
b=5
No comments:
Post a Comment
SAY HELLO!!