Multiple choice

void main() { int a = 123, b = 456; a ^= b ^= a ^= b; printf("%d %d",a,b); }

  1. 123 456

  2. 123 123

  3. 456 456

  4. 456 123

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This XOR swap algorithm exchanges values without a temporary variable. a ^= b means a = a XOR b. The chained XOR operations work because XOR is reversible. Let's trace: Initially a=123, b=456. After all operations, a becomes 456 and b becomes 123. The XOR-swap technique correctly swaps the values.