#include <stdio.h> #include <stdint.h> uint8_t is_bit_set(uint8_t reg, uint8_t pos) { // Your code here return ( (reg >> pos) & 1 ); } int main() { uint8_t reg, pos; scanf("%hhu %hhu", ®, &pos); printf("%u", is_bit_set(reg, pos)); return 0; }
-> shift the specific bit, that is to be checked to the LSB.-> AND it with 1 and return the value of the operation ; if its 1 the bit is set else otherwise.
Test Cases
Test Results
Input
4 2
Expected Output
1