Using only two variables (A and B) and also using only (addition or subtraction), make the value of A become the value of B and the value of B becomes the value of A.
Using only two variables (A and B) and also using only (addition or subtraction), make the value of A become the value of B and the value of B becomes the value of A.
Can it be using the or-exclusive operator? If so:
#include <stdio.h>
int main() {
int a = 123;
int b = 456;
printf("%d %d\n", a, b);
a ^= b;
b ^= a;
a ^= b;
printf("%d %d\n", a, b);
return 0;
}
Here's the output:
123 456
456 123