Let n = 6, i = 2
int mask = 1 << i;
cout << n&mask;
What should be the output and why? It is giving a very unexpected output
Let n = 6, i = 2
int mask = 1 << i;
cout << n&mask;
What should be the output and why? It is giving a very unexpected output
int main() {
int n=6;
int i=2;
int mask = 1 << i; //// === 1* 2^i = 2^2=4
cout << (n&mask); ////6&4==4 i.e the output too
}