What will be displayed after this code fragment is executed?
  int x = 0;
  int y = 0;

  if (x++ && y++)
  {
    y += 2;
  }
  
  cout << x + y;
Explanation
In the beginning, the && operator (also as ||) checks the left operand, and if it is equal to false, the second operand will not be checked and the result of the operation will be false.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes