QP School

Full Version: Bit manipulation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Bit manipulation involves performing operations at the bit level.

// Setting a bit using bitwise OR (|)
int num = 5; // Binary: 0101
int mask = 1; // Binary: 0001
int result = num | mask; // Binary: 0101 | 0001 = 0101
printf("%d\n", result); // Output: 5