Swap every two bits in bytes
Submissions: 2411   Accuracy:

52.21%

  Difficulty: Easy   Marks: 2

Swap all the pair of bits in a byte.
Before swapping: 11-10-11-01
After swapping: 11-01-11-10
Input:
The first line of the input contains an integer T denoting the number of test cases. Each test case contains an unsigned integer x.

Output:
For each test case, the output is the integer after swapping the bits.

Constraints:
1<=T<=100
1<=x<=255

Example:
Input:

2
4
20
Output:
8
40

** 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.