#include <stdio.h> #define BIT_SET 1 #define BIT_NOT_SET 0 int isKthBitSet(int num, int pos) { // Write your code here return (num & (1 << pos))?BIT_SET:BIT_NOT_SET; } int main() { int number, bit_position; scanf("%d %d", &number, &bit_position); printf("%d", isKthBitSet(number, bit_position)); return 0; }
Test Cases
Test Results
Input
8 3
Expected Output
1