Question DSA-BIT-0048
MediumHow can two integers a and b be swapped without a temporary variable using XOR?
- A.
a = b; b = a
- B.
a ^= b; b ^= a; a ^= b
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Bit Manipulation question
How can two integers a and b be swapped without a temporary variable using XOR?
a = b; b = a
a ^= b; b ^= a; a ^= b
Sign up free to see the answer and a step-by-step explanation.
a |= b; b |= a
a &= b; b &= a