In C++ the result of anything mod 0
is undefined behavior, from the draft C++ standard section 5.6
Multiplicative operators paragraph 4 says (emphasis mine):
The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined.[...]
Also, using uninitialized variables is also undefined behavior, so the behavior of this program is unpredictable.