+ 1
How to swap 2 values using only 2 variables..??
Not using any temporary variable
2 Answers
+ 3
This is a well known trick. But you need to be careful when a+b is overflowing the corresponding data type.
a = a+b;
b = a-b;
a = a-b;
+ 22
//so many same question already exist , u can search before posting a question
//might be marked as [duplicate] soon
https://www.sololearn.com/Discuss/245511/?ref=app
https://www.sololearn.com/Discuss/564903/?ref=app
https://www.sololearn.com/Discuss/811929/?ref=app