All submissions

 

#include <stdio.h>
#include <stdint.h>

uint8_t is_bit_set(uint8_t reg, uint8_t pos) {
    // Your code here
    /*
    is this bit ON (True) if not (False)
    reg&(1<<pos) always check if pos bit is set then makes it True else returns False
    */
    if(reg&(1 << pos))
    {
        return 1;
    }
    else
    {
        return 0;
    }
   
}

int main() {
    uint8_t reg, pos;
    scanf("%hhu %hhu", &reg, &pos);
    printf("%u", is_bit_set(reg, pos));
    return 0;
}

 

 

 

 

Loading...

Input

4 2

Expected Output

1