Print ' K ' th least significant bit of a number | CPP code to print ' K ' th LSB ; Function returns 1 if set , 0 if not ; Driver code ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool LSB ( int num , int K ) { return ( num & ( 1 << ( K - 1 ) ) ) ; } int main ( ) { int num = 10 , K = 4 ; cout << LSB ( num , K ) ; return 0 ; }