int i = 1, j = 2, k;
k = i % ++j
I don't understand why k
would equal 1. I figured it what equal 0 because wouldn't the fraction 1/3 round down to 0? Thank you!
int i = 1, j = 2, k;
k = i % ++j
I don't understand why k
would equal 1. I figured it what equal 0 because wouldn't the fraction 1/3 round down to 0? Thank you!
It's actually the remainder. Since three divided into 1 zero times, you have a remainder of one. 1 / 3(using integer arithmetic) is where you would expect the zero.
https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/what-is-modular-arithmetic should be a good link