Check if K-th Bit is Set

Solving Approach

How do you plan to solve it?

 

 

Code

#include <stdio.h>

int isKthBitSet(int n, int k) {
    // Write your code here
    return (((n>>k) & 0x01) == 1)? 1:0;
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    printf("%d", isKthBitSet(n, k));
    return 0;
}

 

Loading...

Input

8 3

Expected Output

1