7. Is the Bit Set

Discussions1
Log in to post comments and replies.
You
Loading editor...
MohanKilari
MohanKilari
Dec 05 2025

#include <stdio.h>

#include <stdint.h>


 

uint8_t is_bit_set(uint8_t reg, uint8_t pos) {

    // Your code here

    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;

}

0