All submissions

Check if K-th Bit is Set

Code

#include <stdio.h>

int main() {
    int N, K;

    scanf("%d %d", &N, &K);

    // Check if K-th bit is set
    if (N & (1 << K))
        printf("1\n");
    else
        printf("0\n");

    return 0;
}

Solving Approach

 

 

 

Loading...

Input

8 3

Expected Output

1