
modulus check digit
Having a little difficulty trying to figure out how to apply the check digit here. I need to be able to select a product item and check it with the "mod 10 check digit". If it fails then I need it to loop and prompt for the product number again. If zero is entered the the prog shoud terminate.
This is actually just a chunk of a project I'm working on...everything else makes sense now. Just need to be able to combine this stuff in there......
#include <stdio.h>
main()
{
int item_number;
while(item_number)
{
printf("\nEnter the item number (zero to quit) > ");
scanf("%i", &item_number);
if(item_number==0)
break;
else if(item_number<0)
/*this is where I want to apply mod check*/
printf("Invalid number, please reenter.");
}
return 0;
}
If I can get the check digit in there, it will also prompt for a correct item number if alpha characters are entered, correct?
Thanks.

sorry forgot to add this.....
this is what I'm working off of.
Technique: mod 10 Check Digit
Source: Encyclopedia of Computer Science and Engineering, Second Edition. "To generate a check digit using the mod 10 technique, work from right to left. First multiply the digits in the odd positions by 2. if an individual result is greater than 10, add 1 to the units position to obtain a single digit adjusted result. Sum the results along with the evenpositioned digits. The number that must be added to make this result evenly divisible by 10 is the check digit." (page 423)
Example: Consider an item number 835174. The least significant digit (4) is the check digit. To determine if the (actual) item number (83517) is a valid item number do the following: 1. Extract the odd numbered digits from right to left from the actual item number. These would be 7, 5 and 8. 2. Multiply each by 2: 7 X 2 = 14, 5 X 2 = 10 and 8 X 2 = 16. 3. If any of the products from step 2 are greater than 10, add 1 to the units position and discard the remainder of the product e.g. since 7 X 2 = 14 add 1 to 4 (the units position) and discard everything else. 4. Sum the adjusted products plus the digits from the even numbered posit ions: 5 + (1) + 10 + (3) + 7 = 26 (the digits in parenthesis are the even numbered digits). 5. The next largest number evenly divisible by 10 is 30 and the difference between 26 and 30 is 4 which is the check digit.