CS50 Credit Pset problem- Code keeps looping back to ask for the credit card number

The following is my code for the Credit Pset from week 1 of CS50, it is not the complete solution to the problem (all the code does (rather is supposed to do) is for the user to enter a credit card number and the program will return the type of card being used, the validity does not matter). Unfortunately, while the program compiles, I used a test case (378282246310005) to check whether the program works or not but it did not work (the program just looped back to the start and asked me to give a credit card number without giving me the solution, which is American Express). I was wondering if anyone could help me on this.

Thanks in advance and please feel free to leave any questions for clarification as the code is not particularly clear nor readable.

#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main(void)
{

long number = get_long("Enter your credit card number: ");

if (number- (long) pow(10, 15) == 0 || (number > (long) pow(10, 15) && (number - (long) pow(10, 15)) < ((long) pow(10, 14))))
{
printf("American Express\n");
}

else if ((number - (long) pow(10, 13) == 0 || (number - (long) pow(10, 13) > 0 && number - (long) pow(10, 13) < (long) pow(10, 12))))
{
printf("Visa\n");

}

else
{
long x = (long) pow(10, 16);
long y = x*(5.1) || x*(5.2) || x*(5.3) || x*(5.4) || x*(5.5);
if ((x == 0 || x > 0) && (x < (long) pow(10, 15)))
{
if (((number == y) || (number - y > 0)) && ((number - y) < (long) pow(10, 15)))
{
printf("MasterCard\n");
}
else
{
printf("Visa\n");
}
}

}

}

The proximate reason for 378282246310005 not being identified as Amex is this

number > (long) pow(10, 15)

is false. Remember pow(10,15) is a 16 digit number.

visual compare for the humans
1,000,000,000,000,000
378,282,246,310,005

I would not expect the posted code to loop back to the start; there is no loop in the code.

• Thank you for relying! While it didn’t solve the entire problem (as it turned out that my code had multiple errors) but it solved a big part of it.