Hint: You are thinking about the decimal system here. In the decimal system, every digit has a value of (digitnumber * 10^(position from the right starting at 0)).
Hint 2: In C++, the '/' operator is a division with remainder when used on integers.
Hint 3: In C++, the '%' operator retrieves the remainder of a division.