πŸ“Š C Programming
Q. After the operation res = (13/5) -2, what will “res” be equal to?
  • (A) 0
  • (B) -2
  • (C) 0,6
  • (D) 2
πŸ’¬ Discuss
βœ… 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

Explanation by: Rudra Pratap Singh
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

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
282
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Rudra Pratap Singh
Publisher
πŸ“ˆ
80%
Success Rate