+ 3
you gotta specify a language
+ 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.
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.