check sum
Description: Most check digit schemes append an extra digit or digits, called the check digit(s), to the identification number and then use the digit(s) to check for errors after the number has been transmitted. To illustrate one possible method, consider the following scenario: A company uses a three-digit number a1a2a3 to identify each product it sells. To make sure these numbers are transmitted correctly, it adds a fourth digit (the check digit) a4; to each product number, creating the four-digit identification number a1a2a3a4. To do this, the first three digits of the number are added, a1+a2+a3, and the check digit a4 is assigned to be the last digit (the ones digit) of this sum. For product number 854, the check digit is 7 since it is the last digit in 8+5+4=17. The identification number is therefore 8547. The number 1090 would be a valid identification number, since the sum of the first three digits is 10 and the last digit of 10 equals the last digit (the check digit) of 1090. The number 7352 would be invalid, however, since the sum of the first three digits is 15 and 5, the last digit of 15 , does not equal 2, the last digit (the check digit) of 7352.
Your job is to write a program that can both generate and validate a checksum digit.
Requirements
the original list
456
754
345
945
123
856 becomes: in the file "generatedValidCodes.txt"
4565
7546
3452
9458
1236
8569
-Where ./a.out is the executable
- input.txt is a file containing the list of number to be checked
- GENERATE or VALIDATE is a flag specifying what we operation is to be performed on the input file
Updated: