bool ok =true;
ok &= (a[i] - a[i - 1] <= 1);
1.whats the "&" means in this code? 2.Is it assignment of any variable?
bool ok =true;
ok &= (a[i] - a[i - 1] <= 1);
1.whats the "&" means in this code? 2.Is it assignment of any variable?
In this context, &=
is the bitwise AND-assignment operator. The value of the variable on the lefthand side (ok
) is AND'ed with the value of the expression on the righthand side ((a[i] - a[i - 1] <= 1)
), and the result is then assigned back to the lefthand variable.