+ 1
(C# Questhion) Why is 19 % 4 = 3?
I can't really understand why does it equals to 3? Why not 4? https://code.sololearn.com/cWMFmlz4Qcvc/?ref=app https://code.sololearn.com/cWMFmlz4Qcvc/?ref=app https://code.sololearn.com/cWMFmlz4Qcvc/?ref=app
4 Respuestas
+ 4
Since the value of y is 2, x + y equals to 19. Then using the modulo operator gives you remainder of 19/4, which is 3.
+ 9
19/4
=4 remainder 3
So, 19%4=3
+ 3
If you divide 19 by 4, remainder is 3 (19=4*4+3), it's saying that .Here % (called ''Modulus'' operator) is used to express this operation.
+ 1
Thank you guys! Now I've understood how it works.