# pset1 credit solution. code not working but there is no bug

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)
{
}
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");
}
}

``````
• You are suffering from a very old disease in programming called the "It cannot be I" syndrome. A programmer convinced themselves that they have done absolutely nothing wrong, yet the program still isn't working. Computers do exactly what they're told but not necessarily what they are intended to do. If a program doesn't do what is expected, there is always a bug or a logic error. It's that simple. Once you embrace that concept, debugging will get a lot easier. Remember, there's a difference between "There is no bug" and "I can't see the bug." Nov 14, 2020 at 23:14