#include <stdio.h>
int isKthBitSet(int n, int k) {
return n & (1 << k) ? true: false;
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
printf("%d", isKthBitSet(n, k));
return 0;
}
Solving Approach
If the nth bit is set return true, if not return false.