3. Check if K-th Bit is Set

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>

int main(){
    int n , k;
    scanf ( "%d %d ", &n ,&k);

    if ( n & (1 << k)) {
        printf ("1\n");

    }else {
        printf ("0\n");
    }
    return 0;
}

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote