Thread: questions re modulus 10 aka check digit stuff

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    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. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    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. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    61
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using getc(stdin) or getchar(c)
    By daedenilus in forum C Programming
    Replies: 11
    Last Post: 11-13-2005, 01:00 AM
  2. Segmentation Fault
    By Lost__Soul in forum C Programming
    Replies: 46
    Last Post: 04-28-2003, 04:24 AM
  3. Scheduling Algo
    By BigDaddyDrew in forum C++ Programming
    Replies: 41
    Last Post: 03-08-2003, 11:00 AM
  4. Heaps...
    By Nutshell in forum C Programming
    Replies: 14
    Last Post: 04-23-2002, 08:54 AM
  5. modulus check digit
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 02-18-2002, 04:04 PM