It was about a credit card problem. So, if the number is 16 digit and the first two digits are 51,52,53,54 or 55, the card is mastercard.
At first, I tried (51 <= j <= 55)
. I thought this condition makes sense. Cause j
is an integer. But for some reason, the error said (51 <= j <= 55)
is always true(I don't understand this!).
So I had to write (j==51 || j==52 || j==53 || j==54 || j==55)
, which is basically the same as (51 <= j <= 55)
.
int j = c / pow(10,14);
if(pow(10,15) <= c < pow(10,16) && (j==51 || j==52 || j==53 || j==54 || j==55))
{
printf("MASTERCARD\n");
}
The code above worked well..(I don't know why)
And I had to make some changes for j
, from double j
to int j
.
I guess it's because that the number 51 to 55 are integers..?
Anyways, the error didn't say anything about pow(10,15) <= c < pow(10,16)
.
Why can't I just use 51 <= j <= 55
?