#include <stdio.h> #include <stdint.h> #define UINT_8_WIDTH 8 uint8_t is_bit_set(uint8_t reg, uint8_t pos) { // Your code here if (pos >= UNIT_8_WIDTH) return 0; return (uint8_t)((reg>>pos)&1u); } int main() { uint8_t reg, pos; scanf("%hhu %hhu", ®, &pos); printf("%u", is_bit_set(reg, pos)); return 0; }
Test Cases
Test Results
Input
4 2
Expected Output
1