3. Check if K-th Bit is Set

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>
#include <stdint.h>

int checkbit(int n,int k) {
	return n & (1 << k) ? 1 : 0 ;

}


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

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote