QuestionQ76

Using Operators and Decision Constructs

Given this code fragment:

Question Image

What is the output?

  • A 2 : 7 : 3
  • B 7 : 7 : 9
  • C 2 : 7 : 0
  • D 7 : 2 : 3
Explanation

With integer arithmetic, multiplication and division have the same precedence and are evaluated from left to right. Integer division truncates fractional results, so 3 / 2 evaluates to 1; the computed values are r1 = 7, r2 = 2, and r3 = 3.

Community Discussion

No comments yet. Be the first to start the discussion!