0

Why int x = 16 ‰ int y = 5 equal 1?

2nd Mar 2017, 2:44 PM
Kovalevich Vladimir
Kovalevich Vladimir - avatar
4 Respostas
+ 4
The modulus operator (%) finds the remainder in an equation. So 16%5 is equal to 1
2nd Mar 2017, 2:50 PM
Chirag Bhansali
Chirag Bhansali - avatar
+ 2
16 divided by 5 is 3 with a remainder of 1. The modulus operator takes the remainder.
3rd Mar 2017, 12:35 AM
Anthony Vanover
Anthony Vanover - avatar
0
One way to find a remainder is like this. How high can you multiply 5 without going over 16? That would be 15, so subtract 15 from 16, and you get 1. The modulus (%) operator gives the remainder back.
2nd Mar 2017, 3:55 PM
Rain
Rain - avatar
0
Think it like 16 mod 5. 3x5=15, 4x5=20. So there is not an integer equal to 16. If you divide 16 with 5 you have 16-15=1 which is the remainder.
3rd Mar 2017, 3:19 AM
Corrina Galetza