GeeksforGeeks » Interview Questions

Qualcomm Interview Question for Software Engineer/Developer (Fresher) about Bit Magic

(2 posts)

Tags:

  1. rahul
    guest
    Posted 4 months ago #

    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

  2. gaurav
    guest
    Posted 4 months ago #

     typedef unsigned char byte;
    
    byte swap (byte a)
    {
              return((a&0x55)<<1)|((a&0xAA)>>1);
    } 

Reply

You must log in to post.

RSS feed for this topic