+ 2

Code to swap two number's without using 3rd variable in java

19th Dec 2017, 4:28 PM
Neeraj Sharma
Neeraj Sharma - avatar
4 Respostas
+ 5
int a=5; int b=7; a=a+b; b=a-b; a=a-b; System. out.print(a);
19th Dec 2017, 4:49 PM
Neeraj Sharma
Neeraj Sharma - avatar
+ 23
In many ways it can be achieved //u just need to think urself , u can use * & / also ... but also be careful bcz a,b can be 0 also☺
19th Dec 2017, 4:50 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 11
int a=10,b=20; System.out.println("A ="+a+" and "+"B= "+b); a=a^b; b=a^b; a=a^b; System.out.println("after swapping A ="+a+" and "+"B= "+b); by this you can swap two numbers
19th Dec 2017, 4:36 PM
GAWEN STEASY
GAWEN STEASY - avatar
0
my answer is easy and right
19th Dec 2017, 4:51 PM
Neeraj Sharma
Neeraj Sharma - avatar