what's is going wrong here.....if I enter 4123456789098 this then by dividing this number with 10^12 then it should be equal to 4 but it is not.......??
JUST IGNORE THE BELOW THING....SORRY FOR THAT!!
jdkjkjdgkdglhdlashghgh oadgjl adfj kjkja kjafj kjapajpjfouqeihqeiy
My code:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
while (true)
{
long long int id = get_long("Number: ") ;
int k = 0 ;
while (id != 0)
{
id = id / 10 ;
k++ ;
}
printf("%i\n", k) ;
// VISA
if (k == 13)
{
int x = id / pow(10 , 12) ;
if (x == 4)
{
printf("VISA\n") ;
break ;
}
else
{
printf("INVALID V\n") ;
}
}
// AMEX
else if (k == 15)
{
int y = id / pow(10 , 13) ;
if (y == 34 || y == 37)
{
printf("AMEX\n") ;
break ;
}
else
{
printf("INVALID A\n") ;
}
}
// VISA or MASTERCARD
else if (k == 16)
{
int z_M = id / pow(10 , 14) ;
int z_V = id / pow(10 , 15) ;
if (z_M >= 51 && z_V <= 55)
{
printf("MASTERCARD\n") ;
break ;
}
else if (z_V == 4)
{
printf("VISA\n") ;
break ;
}
else
{
printf("INVALID V or A\n") ;
}
}
}
}
Output:
Number: 4123456789098
13
INVALID V
Expected Output:
Number: 4123456789098
13
VISA
Thanx in advance for any suggestions....!!
Aucun commentaire:
Enregistrer un commentaire