codegurukool.com · Free coding tutorials & online compiler

Home › C Tutorial › C bitwise operators

C bitwise operators

Work on individual bits.

& | ^ ~ << >>. Shifting left by n multiplies by 2 to the power n.

Example code

#include <stdio.h>
int main() {
  int a = 6, b = 3;
  printf("%d %d %d %d %d\n", a & b, a | b, a ^ b, a << 1, a >> 1);
  return 0;
}

Run this code in the online editor

← C storage classesC fixed-width integers →