Code

#include <stdio.h>
#include <stdint.h>
int isBitSet(unsigned char reg, int pos){
    return (reg &(1 << pos))? 1:0;
}
int main(){
    unsigned char reg;
    int pos;
    scanf("%hhu %d", &reg, &pos);
    printf("%d\n", isBitSet(reg, pos));
    return 0;
}

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

4 2

Expected Output

1