XOR of two numbers after making length of their binary representations equal
Submissions: 641   Accuracy:

55.82%

  Difficulty: Easy   Marks: 2

Given two numbers say a and b. Print their XOR after making the lengths of their binary representation equal by adding trailing zeros to the binary representation of smaller one.

Input:
The first line of the input contains integer T denoting the number of test cases. For each test case, there are two integer inputs a &
b. 

Output:
For each test case, the output is the integer displaying the  XOR of a & b after making them of equal lengths.

Constraints:
1<=T<=100

1<=a,b<=107

Example:
Input:

4
2 6
3 10
5 24
1 20
Output:
2
6
12
4

Explanation:
1. The binary representation of 2 is 10 and of 6 is 110. As the length of "10" is smaller, so add a '0' to it making it "100', to make the length of binary representations equal. XOR of 100 and 110 gives 010 which is 2.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vanshika
Author: Vanshika_pec


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.