Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- switch (option)
- {
- case 13:
- {
- int identityCard = 0, rightPartOfTheNumber = 0, checkDigit = 0, sum = 0, i = 0, counter = 0;
- bool doubleOrOddDigit = true, isSumTrue = true;
- cout << "please enter your id : ";
- cin >> identityCard;
- checkDigit = identityCard % 10;
- identityCard /= 10;
- for (i = 0; identityCard > 0; counter++)
- {
- rightPartOfTheNumber = identityCard % 10;
- if (doubleOrOddDigit)
- {
- rightPartOfTheNumber *= 2;
- sum += rightPartOfTheNumber % 10 + rightPartOfTheNumber / 10;
- }
- else
- sum = sum + identityCard % 10;
- identityCard /= 10;
- doubleOrOddDigit = !doubleOrOddDigit;
- }
- if ((sum + checkDigit) % 10 != 0)
- {
- isSumTrue = false;
- }
- if (isSumTrue)
- cout << "you wrote correct id \n";
- else
- cout << "you wrote incorrect id \n";
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment