Advertisement
bool x=true, y=false;
if(~x || y){
/*part A*/
}
else{
/*part B*/
}
- Part A executes because the expression (~x || y) always results in true if y==false.
- Part B executes because the statement (~x || y) is invalid, thus false.
- Part A executes because ~x is not zero, meaning true.
- Part B executes because ~x is false and y is false, thus the OR operation evaluates as false.
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.