GeeksforGeeks » Interview Questions
Qualcomm Interview Question for Software Engineer/Developer (Fresher) about Bit Magic
(2 posts)-
Given a byte, write a code to swap every two bits. [Using bit operators] Eg: Input: 10 01 11 01 Output: 01 10 11 10
-
typedef unsigned char byte; byte swap (byte a) { return((a&0x55)<<1)|((a&0xAA)>>1); }
Reply
You must log in to post.