Find XOR of two number without using XOR operator - GeeksforGeeks
Find XOR of two number without using XOR operator
Given two integers, find XOR of them without using XOR operator, i.e., without using ^ in C/C++.
Examples:
Input: x = 1, y = 2 Output: 3 Input: x = 3, y = 5 Output: 6
We strongly recommend you to minimize your browser and try this yourself first.
A Simple Solution is to traverse all bits one by one. For every pair of bits, check if both are same, set the corresponding bit as 0 in output, otherwise set as 1.
Read full article from Find XOR of two number without using XOR operator - GeeksforGeeks
No comments:
Post a Comment