So, I have gotten rid of all the errors and got the code to the point to prompt the user for the credit card number and output an answer the only problem is the program falls thru to invalid every time and never prints a credit card brand. The updated code is posted below any help is appreciated.
Thank you,
#include <stdio.h>
#include <cs50.h>
#include <math.h>
#include <string.h>
long checklength();
long checksum();
long cardBrand(long askPositiveLong, long checklength, long checksum);
int main()
{
long positiveLong = 0;
int ccn = 0;
long askPositiveLong;
do
{
askPositiveLong = get_long("Enter valid credit card # ");
}while(askPositiveLong < 0);
printf("%li\n", cardBrand(ccn, positiveLong, askPositiveLong));
}
long checklength(ccn)
{
if(ccn == 13 || ccn == 15 || ccn == 16)
{
return true;
return false;
}
return ccn;
}
long checksum(positiveLong)
{
int sum = 0;
for(int i = 0; i > positiveLong; i++)
{
if (i % 10 == 0)
{
int digit = (2*(positiveLong%10));
sum += (digit/10 + digit%10);
}
else
{
sum += (18/10 == 1) + (18%10 == 8);
}
}
if(sum % 10 == 0)
{
return true;
return false;
}
return positiveLong;
}
long cardBrand (long askPositiveLong, long checklength, long checksum)
{
if (askPositiveLong >= 340000000000000 && askPositiveLong < 350000000000000)
{
printf("AMEX\n");
}
else if (askPositiveLong >= 370000000000000 && askPositiveLong < 380000000000000)
{
printf("AMEX\n");
}
else if (askPositiveLong >= 5100000000000000 && askPositiveLong < 5600000000000000)
{
printf("MASTERCARD\n");
}
else if (askPositiveLong >= 4000000000000 && askPositiveLong < 4100000000000)
{
printf("VISA\n");
}
else if (askPositiveLong >= 4000000000000000 && askPositiveLong < 4100000000000000)
{
printf("VISA\n");
}
else
{
printf("INVALID");
}
return askPositiveLong;
}
edit
button under the question, select the code, hit the{}
in the format bar et voilà.