0

How could we swap two number(in C language) without using third veriable as well as without using arithematic operators?

14th Oct 2019, 7:33 AM
Amit Dubey
Amit Dubey - avatar
6 ответов
+ 2
Not sure if this helps as it uses arithmetic operators, ... a = a + b b = a - b a = a - b
14th Oct 2019, 4:21 PM
rodwynnejones
rodwynnejones - avatar
+ 2
Thanks😊
14th Oct 2019, 5:01 PM
Amit Dubey
Amit Dubey - avatar
+ 1
Im not sure that there is another way without doing some super elaborate thing
14th Oct 2019, 7:40 AM
Trigger
Trigger - avatar
+ 1
A less known method using addition and subtraction, limited to integers too: #define SWAP(a, b) ((a) -= (b), (b) += (a), (a) = (b) - (a))
14th Oct 2019, 4:11 PM
Bilbo Baggins
Bilbo Baggins - avatar