169: Make a Credit Card Validator Program in C++ (1. Double every second digit from right to left, If doubled number is 2 digits, split them (9 x 2 = 18, 1 and 8).) (2. Add all single digits from step 1.) (3. Add all odd numbered didgits from right to left.) (4. Sum results from steps 2 & 3.) (5. If step 4 is divisible by 10, credit card # is valid.)
// Make a Credit Card Validator Program in C++ // (1. Double every second digit from right to left, If doubled number is 2 digits, // split them (9 x 2 = 18, 1 and 8).) // (2. Add all single digits from step 1.) // (3. Add all odd numbered didgits from right to left.) // (4. Sum results from steps 2 & 3.) // (5. If step 4 is divisible by 10, credit card # is valid.) // 4032-6426-9444-5720 #include < iostream > using namespace std ; bool isValid ( string x ); int even_sum ( string x , int size ); // get sum of double of even numbers and broken values from rigth to left int odd_sum ( string x , int size ); // get sum of odd values from right to left int get_num ( string x , int i ); // gets number at position i of string int main () { string card ; cout << " Enter your credit card number (without spaces): " ; cin >> card ; if ( isValid ( card )) ...