Check if K-th Bit is Set

Code

#include <stdio.h>
int main(){
    int N,K;
    scanf("%d %d",&N,&K);
    if((N>>K)&1)
    printf("1");
    else
        printf("0");
   return 0;
    
}

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Input

8 3

Expected Output

1