A

Admin • 833K Points
Coach

Q. After the operation res = (13/5) -2, what will “res” be equal to?

  • (A) 0
  • (B) -2
  • (C) 0,6
  • (D) 2
  • Correct Answer - Option(A)
  • Views: 25
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

In C the operator / applied to two integers, performs the integer division.

In mathematics the integer division gives two results:
– The quotient
– The remainder

13/5 gives
– The quotient = 2
– The remainder = 3
13 = 5 * 2 + 3

In C, the / operator gives the quotient and the % operator gives the remainder
13/5 gives the quotient = 2
13%5 gives the remainder = 3

13 = 5 * (13/5) + 13%5

So: res = 2 – 2 = 0

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.