INSERT GRAPHIC HERE (include hyperlink in image)
Subtitle or Short Description Goes Here
| #include <math.h> // library for pow() | |
| #include <cs50.h> // library for get_long() | |
| #include <stdio.h> // library for almost all C functions | |
| int countDigits(long card); // initialise the function to count the number of digits before the main function | |
| int sumDigits(long card, int len, unsigned long long int power); // initialise the function to check the Luhn sum | |
| int main(void) | |
| { | |
| // PROMPT THE CARD NUMBER (INPUT) |
| Initialise the 1stsub function to count the number of digits before the main function | |
| Initialise the 2nd sub function to check the Luhn sum | |
| Main funtion | |
| // PROMPT THE CARD NUMBER (INPUT) | |
| Initialise the type of card (from 13 to 16 digits) | |
| Get the card number from user | |
| Avoid the negative long and 0 | |
| // GET THE DIGIT COUNT TO CHECK FOR THE CARD'S LENGTH => CARD'S TYPE |