Please login/signup to upvote submissions.
1

Check if K-th Bit is Set

All submissions
RohitTelkar

RohitTelkar

Code

#include <stdio.h>

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

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

 

Submit Your Solution