Computer Science, asked by priya333, 1 year ago

plzzzz...give a java program on swaping 2 numbers without using a variable

Answers

Answered by chiekou
2
import java.util.*;
class swap
{
int a,b;
void display()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter 2 numbers");
a=sc.nextInt();
b=sc.nextInt()
a=a+b;
b=a-b;
a=a-b;
System.out.println("a="+a);
System.out.println("b="+b);
}
}
NOW YOU CAN DRY RUN PRIYA OUTPUT WOULDCOME

chiekou: PRIYA IS IT HELPFUL.....COMPILE IT......AND THEN RUN IT.....
Similar questions