+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!

6/22/2019 11:56:41 PM

UrBoyO

3 Answers

New Answer

+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