+ 2
[CLOSED] What happens if the dividend is smaller than the divisor with modulus operator?
I've seem this case a few times and I don't know how to solve it... I can't tell what it outputs!! Examples: 1) 2 % 3 2) Int x = 3; x += x % 4; cout << x; Thank you!
3 ответов
+ 8
1. 2 % 3 == 2.
2. 3 % 4 == 3.
In general, for n<m natural numbers we have n % m == n.
+ 3
@Diego Thank you!! This helps a lot! 😃
0
It returns the dividend value as the output