I came upon this interview question through a link from LinkedIn and I know what an XOR does, but at the same time I am not comfortable with bit shifting and stuff like that, if I don't have to do it I try not to make things overly complicated for myself.
But I would really like to understand more about how these things work in the case that I find a good use case in the future.
Predict the output for the below program
public class Program { public static void Main(string[] args) { int x = 1975; int y = 2015; x ^= y ^= x ^= y; Console.WriteLine("x = " + x + "; y = " + y); } }
it gives the output
x = 0;Y=1975
Can someone please break this into steps to explain what exactly is going on in this line of code? order of assignment, etc?
x ^= y ^= x ^= y;