C Bitwise Operators

Manipulate raw bits directly using AND, OR, XOR, NOT, and shift operators.

Bitwise operators work at the binary bit level. They are essential for systems programming, device driver development, cryptography, and embedded systems:

  • & (AND), | (OR), ^ (XOR), ~ (NOT)
  • << (Left shift), >> (Right shift)

Key Takeaways: C Bitwise Operators

Mastering C Bitwise Operators helps you write clean and reliable C code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

C Bitwise Operators Code Example

C
#include <stdio.h>

int main() {
    unsigned char a = 5;  // 00000101
    unsigned char b = 9;  // 00001001

    printf("a & b = %d\n", a & b);
    printf("a | b = %d\n", a | b);
    printf("a << 1 = %d\n", a << 1);
    return 0;
}
Output
a & b = 1
a | b = 13
a << 1 = 10
Run this example on your own computer. The "Get Started" lesson shows how to set it up.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services