Q. After the operation res = (13/5) -2, what will “res” be equal to?
β
Correct Answer: (A)
0
Explanation: 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