Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the value of x after executing the following statement?

int x = 011 | 0x10;

  • A.13
  • B.19
  • C.25
  • D.27

Answer: C

Correct answer: 25

The two literals are in different bases: a leading 0 marks octal and 0x marks hexadecimal.

\[ 011_8 = 9 = 01001_2, \quad 0x10 = 16 = 10000_2 \]

The bitwise OR sets every bit that is set in either, giving \(11001_2 = 25\).

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.