What results from executing this code snippet?

Advertisement

int x=5, y=2;
if(x & y) {
/*_part A_*/
}
else {
/*_part B_*/
}

  • Part A executes because x==5 (true) and y==2 (true), thus the AND operation evaluates as true.
  • Part B executes because (x & y) results in 0, or false.
  • Part A executes because (x & y) results in a nonzero value, or true.
  • Part B executes because the statement (x & y) is invalid, thus false.
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.