+ 3
you gotta specify a language
14th Aug 2018, 1:48 PM
᠌Bidex
᠌Bidex - avatar
+ 1
In languages which allow multiple values per expression you can do: a, b = b, a Otherwise: You can do integers like this: a = a + b b = a - b a = a - b You can do it in assembly by loading a and b into r0 and r1, and then writing r0 to b and r1 to a.
14th Aug 2018, 1:14 PM
Vlad Serbu
Vlad Serbu - avatar
0
you cant in java, atleast i think! i mean how would that be possible because with only two variables how would you swap the values? once you assign value2 to value1 value1 is gone, and vice versa. but other languages may differ.
14th Aug 2018, 1:10 PM
StealthyTaco
StealthyTaco - avatar