Write a program in JAVA to swap number without using 3rd variable
import java.util.*;
class swaping
{
public static void main (String obj[])
{
int a , b;
Scanner sc=new scanner (system.in);
System.out.println (“Enter the value of a & b”);
a=sc.nextInt ();
b = sc.nextInt ();
a=a+b;
b=a-b;
a=a-b;
system.out.println(“Value of a & b is=”+a+” “+b);
}
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment