C++ program to swap all odd bits with even bits (swap adjacent bits). Every even positiC++ program to swap all odd bits with even bits (swap adjacent bits). Every even position bit is swapped with an adjacent bit on the right side and every odd position bit is swapped with adjacent on the left side. For instance, 13(00001101) should be converted to 14(00001110) .on bit is swapped with an adjacent bit on the right side and every odd position bit is swapped with adjacent on the left side. For instance, 13(00001101) should be converted to 14(00001110).
Input format: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an unsigned integer N.
Output format: Corresponding to each test case, print in a new line, the converted number.
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 100
Example:
Input:
2
13
2
Output:
Original number is : 13
Converted number is : 14
Original number is : 2
Converted number is : 1
Algorithm:
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer