#include <iostream>
int main() {
// Step 1: Define a byte (8 bits)
unsigned char byte = 0b11011010;
// Step 2: Define the position of the bit to extract (0-based index)
int bitPosition = 3;
// Step 3: Create a bitmask to isolate the desired bit
unsigned char bitmask = 1 << bitPosition;
// Step 4: Use bitwise AND to extract the bit value
unsigned char extractedBit = (byte & bitmask) >> bitPosition;
// Step 5: Output the result
std::cout << "Bit at position " << bitPosition << " is: " << static_cast<int>(extractedBit) << std::endl;
return 0;
}