Multiple choice

What is the output of the given code?

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

  1. 64

  2. 59

  3. 62

  4. 63

  5. 77

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

The compiler will first convert all of the given values in binary form. So, value of x in binary is 00011000, value of Y in binary is 00101010, value of Z in binary is 00100101 and value of "a" in binary is 00010110. Now, OR operation will be performed on all of them to obtain a single result: (00011000) | (00101010) | (00100101) | (00010110). It will result in 63. So, this is the correct answer.