#include <stdio.h>
int isKthBitSet(int n, int k) {
// Write your code here
return ((n >> k) & 1U);
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
printf("%d", isKthBitSet(n, k));
return 0;
}
Solving Approach
Shift N for K times towards LSB and isolate it with an AND mask (to keep only the first bit)