credit.c
int checksum(long long int num, int count)
{
    int digit = 0;
    int sum = 0;
    int digit1 = 0;
    int sum1 = 0;
    long long int num1 = 0;
    int lastdigit = 0;

    // loop through each sdigit and multiple by 2 / summation based on the algorithm
    for (int i = 1 ; i <= count ; i++)
    {
        digit = num % 10;
        num = num / 10;

        if (i % 2 == 0)
        {
            num1 = digit * 2;

            if (num1 >= 10) // check if more then 1 digits after x2
            {
                digit1 = num1 % 10;
                num1 = num1 / 10;
                sum1 = num1 + digit1; // add the two digits together
                sum = sum + sum1;
            }
            else
            {
                sum = sum + num1;
            }
        }
        else
        {
            sum = sum + digit;
        }
    }
    lastdigit = sum % 10;
    return lastdigit;
}
// second function to conduct checksum using Luhn's algorithm
second function to conduct checksum using Luhn's algorithm
second function to conduct checksum using Luhn ' s algorithm
int checksum(long long int num, int count)
{
    int digit = 0;
    int sum = 0;
    int digit1 = 0;
    int sum1 = 0;
    long long int num1 = 0;
    int lastdigit = 0;
    for (int i = 1 ; i <= count ; i++)
    {
        digit = num % 10;
        num = num / 10;
        if (i % 2 == 0)
        {
            num1 = digit * 2;
            if (num1 >= 10) 
            {
                digit1 = num1 % 10;
                num1 = num1 / 10;
                sum1 = num1 + digit1; 
                sum = sum + sum1;
            }
            else
            {
                sum = sum + num1;
            }
        }
        else
        {
            sum = sum + digit;
        }
    }
    lastdigit = sum % 10;
    return lastdigit;
}
int checksum ( long long int num , int count ) { int digit = 0 ; int sum = 0 ; int digit1 = 0 ; int sum1 = 0 ; long long int num1 = 0 ; int lastdigit = 0 ; for ( int i = 1 ; i <= count ; i ++ ) { digit = num % 10 ; num = num / 10 ; if ( i % 2 == 0 ) { num1 = digit * 2 ; if ( num1 >= 10 ) { digit1 = num1 % 10 ; num1 = num1 / 10 ; sum1 = num1 + digit1 ; sum = sum + sum1 ; } else { sum = sum + num1 ; } } else { sum = sum + digit ; } } lastdigit = sum % 10 ; return lastdigit ; }
second function to conduct checksum using Luhn's algorithm
second function to conduct checksum using Luhn ' s algorithm
// loop through each sdigit and multiple by 2 / summation based on the algorithm // check if more then 1 digits after x2 // add the two digits together