# questions re modulus 10 aka check digit stuff

This is a discussion on questions re modulus 10 aka check digit stuff within the C++ Programming forums, part of the General Programming Boards category; I would appreciate any help with this subject. I am currently attempting to write a program that utilizes check-digit code ...

1. ## questions re modulus 10 aka check digit stuff

I would appreciate any help with this subject. I am currently attempting to write a program that utilizes check-digit code provided by the instructor. Could someone explain to me in plain words how the modulus 10 operator works. The light just hasn't come on regarding this subject and it is hindering my progress with the rest of the program. Any help/explanations would be greatly appreciated.

Thanks!

2. The modulus is the remainder you get when you do long division.

So, 64 % 10 would be the remainder of 64/10. If you remember long division, 64/10 is 6 remainder 4, so 64%10 = 4.

In base 10 arithmetic, any positive integer % 10 is equal to the value of the "ones" digit of that number.

So:

12 % 10 = 2
4 % 10 = 4
100 % 10 = 0
76876371 % 10 = 1

3. Well the modulus operator (%) returns the remainder of a divison so 5 % 2 is equal to 1 because 5/2 is equal to 2 remainder 1. When you modulus a number by ten it returns the value of the right-most digit.
For ex.

1234 % 10 is equal to 4 because 1234/10 equals 123 remainder 4.

Hope this helps.