I wrote this code and I can "make credit". However, when I tested it with numbers, it doesn't work.
Please see my code below.
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
int number = get_int("Number: ");
int sumofln;
int sumofeon;
for (int n = 1; n < 17; n = n + 2)
{
int i = pow(10, n);
int eon = number % i; //eon = every other number
sumofeon = 0;
sumofeon = sumofeon + eon; //sumofeon = sum of every other number
}
for (int n = 0; n < 17; n++)
{
int j = pow(10, n);
int ln = number % j; //ln = left numbers
sumofln = 0; //sumofln = sum of left numbers
sumofln = sumofln + ln;
}
int total;
total = sumofln + sumofeon;
if (total % 10 == 0)
{
if ((number % 1000000000000000) == 4) //VISA - 16
{
printf("VISA\n");
}
else if ((number % 1000000000000000) == 5) // MASTERCARD
{
if ((number % 100000000000000) < 6)
{
printf("MASTERCAD\n");
}
else
{
printf("INVALD\n");
}
}
else if (number % 1000000000000000 == 0 && number % 100000000000000 == 3) //AMEX
{
if (number % 10000000000000 == 4 || number % 10000000000000 == 7)
{
printf("AMEX\n");
}
else
{
printf("INVALID\n");
}
}
else if ((number % 1000000000000000 + number % 100000000000000 + number % 10000000000000) == 0) //VISA - 13
{
printf("VISA\n");
}
else
{
printf("INVALID\n");
}
}
else
{
printf("INVALID\n");
}
}