+ 1
[DUPLICATE] Ouestion
how to swap two numbers without using a third variable.
11 Answers
+ 19
//duplicate : make use of search bar , many similiar questions already exists
https://www.sololearn.com/Discuss/575040/?ref=app
+ 10
int a;
int b;
a=a+b;
b=a-b;
a=a-b;
+ 10
@Ace... now you're just being hurtful and hitting below the belt. Let's try to remain civil here. đ đĄđ€Źđ€Ż
đ€ŁI'm sure there is something you are thinking about and I am missing. But, logical operators also exist in Javascript:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_logical_operators
Oh... and as another person who is well acquainted with PHP, feel free to hate on that as much as you'd like.
The enemy of my enemy is my friend. đ€
+ 9
@Ace... Did you go and pull bitwise operators out of Javascript again? Eh hem... give back and stop picking on the little web languages. đ
Seriously though, Javascript supports XOR. IIRC It's been around since ECMA 1.0. I'd need to verify though.
+ 9
here's what I did. https://code.sololearn.com/cpfZl01t20Qr/?ref=app
+ 5
ace what languages is the xor applicable?
+ 4
I don't know,@ace seems to have something against web,verified it exists in php,i really really doubt JavaScript
+ 2