I have a task to solve:
I must enter a positive integer N and 0 < B < 31 and print the B-th bit of number N (potential of digit 2B in binary number N).
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
int main(){
int N, B;
cout << "Insert N = ";
cin >> N;
do{
cout << "Insert B = ";
cin >> B;
}
while(B < 1 || B > 31);
And here I stoped. I have no idea what to do next.
Any ideas?