Bitwise Operators
& | ^ ~ << >> work on bits. They are used for flags and masks.
Example
#include <stdio.h>
int main(void) {
unsigned f = 0;
f |= 1u << 2;
f |= 1u;
printf("%u %u %u\n", f, f & 4, f ^ 1);
return 0;
}Result
5 4 4
Exercise
Shift left.
1 3
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.