<syntaxhighlight lang="c" name="bitwise">
int main() {
int a; printf("Enter a number\n"); scanf("%d", &a); printf("The third bit (from right) of %d is made 0 and we get %d\n", a, a& (-1<<3 | 11)); // -1 has all bits 1, so -1<<3 will have the rightmost 3 bits 0 and rest 1, and -1<<3 | 11 will have the 3rd bit from right as 0 and all other bits 1
} </syntaxhighlight>
<syntaxhighlight lang="c" name="bitwisenot">
int main() {
unsigned int a; printf("Enter a number\n"); scanf("%u", &a); printf("Negation of %u is %u\n", a, ~a); //~a will have all bits of a inverted (0's become 1 and 1's become 0)
} </syntaxhighlight>
<syntaxhighlight lang="c" name="leftshift">
int main() {
int a, b; printf("Enter a number and a power of 2\n"); scanf("%d %d", &a, &b); printf("%d multiplied by %d is\n", a, a << b); //<< is usually preferred to *
} </syntaxhighlight>
<syntaxhighlight lang="c" name="rightshift">
int main() {
int a, b; printf("Enter a number and a power of 2\n"); scanf("%d %d", &a, &b); printf("%d divided by %d is\n", a, a >> b); //>> is usually preferred to *
} </syntaxhighlight>
<syntaxhighlight lang="c" name="bitwise">
int main() {
int a; printf("Enter a number\n"); scanf("%d", &a); printf("The third bit (from right) of %d is made 0 and we get %d\n", a, a& (-1<<3 | 11)); // -1 has all bits 1, so -1<<3 will have the rightmost 3 bits 0 and rest 1, and -1<<3 | 11 will have the 3rd bit from right as 0 and all other bits 1
} </syntaxhighlight>
<syntaxhighlight lang="c" name="bitwisenot">
int main() {
unsigned int a; printf("Enter a number\n"); scanf("%u", &a); printf("Negation of %u is %u\n", a, ~a); //~a will have all bits of a inverted (0's become 1 and 1's become 0)
} </syntaxhighlight>
<syntaxhighlight lang="c" name="leftshift">
int main() {
int a, b; printf("Enter a number and a power of 2\n"); scanf("%d %d", &a, &b); printf("%d multiplied by %d is\n", a, a << b); //<< is usually preferred to *
} </syntaxhighlight>
<syntaxhighlight lang="c" name="rightshift">
int main() {
int a, b; printf("Enter a number and a power of 2\n"); scanf("%d %d", &a, &b); printf("%d divided by %d is\n", a, a >> b); //>> is usually preferred to *
} </syntaxhighlight>