![]() Hope this will be useful to beginner programmers. But I forgot to post the answer of this the question. I solved this problem 2 years ago from now. If (digitcounter = 15 & (initdigit = 34 || initdigit = 37))Įlse if (digitcounter = 16 & (initdigit >= 51 & initdigit <=55))Įlse if ((digitcounter = 13 || digitcounter = 16) & tempinitdigit = 4) increase digitcounter by 1 in each iteration remove last digit from ccnum in each iteration Initdigit = tempinitdigit // initdigit will hold the first two digits. Long long initdigit = 0, tempinitdigit = 0 It uses the Luhn algorithm to verify the credit card number and identify the type of credit card. Sum = sum + (tempmultiply % 10) + (tempmultiply / 10) C++ was used to create the Credit Card Validator application. Case-02(Multiplication every other digit by 2): If the total’s last digit is 0 (or, put more formally, if the total modulo 10 is congruent to 0), the number is valid! //Project Using Luhn's Algorithm - Credit Card validationĬcnum = get_long("Enter your credit card number: ") Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products’ digits together.Īdd the sum to the sum of the digits that weren’t multiplied by 2. According to Luhn’s algorithm, you can determine if a credit card number is (syntactically) valid as follows: Most cards use an algorithm invented by Hans Peter Luhn of IBM. I wrote this code but whenever I put any credit card number, the output comes as invalid.Can anyone please help me what my mistake here and how can I move forward with this code. This a problem from CS50 finding validation of credit card number using luhn's algorithm.
0 Comments
Leave a Reply. |