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

Discussion

What is the value of x in this C code?    

void main()
    {
        int x = 4 *5 / 2 + 9;
    }

 

  • A.6.75
  • B.1.85
  • C.19
  • D.3

Answer: C

Correct answer: 19

* and / bind tighter than + and, having equal precedence, associate left to right:

\[ 4 \times 5 = 20, \quad 20 / 2 = 10, \quad 10 + 9 = 19 \]

Every step is integer arithmetic, so the answer is exactly 19.

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

Post your comment

Please log in or register to post a comment.