Multiple choice

What is the output of the given program?

int main()
{
 int x = 24;
 int y = 42;
 int z = 37;
 int a = 22;
 printf(%d,x&y|z^a);
 }

  1. 60

  2. 59

  3. 58

  4. 57

  5. 56

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct answer. The operators used here are all bitwise operators which operate on binary bits. So, the value of x in binary is 00011000, the value of  Y in binary is 00101010 and the value of Z in binary is 00100101. The value of variable "a" in binary is 00010110. The expression becomes [ 000011000 & 00101010 | 00100101 ^ 00010110 ]. So, we will evaluate 24 and 42 | 37 ^ 22, which results in 59.