#include <iostream>
using namespace std;
bool n_bit_set(int num, int N) {
return num & (1 << (N - 1));
}
int main() {
int num = 12; // 1100
int N = 3;
if (n_bit_set(num, N)) {
cout << "Bit set" << endl;
}
else {
cout << "Bit not set" << endl;
}
N = 1;
if (n_bit_set(num, N)) {
cout << "Bit set" << endl;
}
else {
cout << "Bit not set" << endl;
}
}
/*
run:
Bit set
Bit not set
*/