Code

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

uint8_t is_bit_set(uint8_t reg, uint8_t pos) {
    // Your code here
    int res=0;
    reg&=(1<<pos);
    if(reg==0)
    {
        res=0;
    }else
    {
        res=1;
    }
    return res;
}

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

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

4 2

Expected Output

1