#include <stdio.h>
int isKthBitSet(int n, int k) {
// Write your code here
return (n>>k)&1;
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
printf("%d", isKthBitSet(n, k));
return 0;
}
Solving Approach
Shifting the kth bit to the 0th bit and perform AND operation with 00000001 to find the status of the required bit.