Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<cs50.h>
- int main (void)
- {
- int sum = 0;
- int q;
- int p;
- long long cc_number;
- int a;
- do
- {
- printf("Enter your credit card number: ");
- cc_number = get_long_long();
- }while (cc_number <0);
- for (long long i=100; i<=pow(10,17); i=i*100)
- {
- q=(cc_number%i)*10/i ;
- q=q*2;
- if (q>9)
- {
- q = (q/10)+(q%10);
- }
- sum = sum + q;
- }
- for(long long i=10; i<=pow(10,16); i=i*100)
- {
- p=(cc_number%i)*10/i;
- sum = sum + p;
- }
- if(sum%10 ==0){
- if(cc_number/pow(10,13) ==34)
- {
- printf("The card is an American Express' card\n");
- }
- else if(cc_number/pow(10,13)==37)
- {
- printf("The card is an American Express' card\n");
- }
- else if (cc_number/pow(10,14)==51)
- {
- printf("The card is a MasterCard's card\n");
- }
- else if (cc_number/pow(10,14)==52)
- {
- printf("The card is a MasterCard's card\n");
- }
- else if (cc_number/pow(10,14)==53)
- {
- printf("The card is a MasterCard's card\n");
- }
- else if (cc_number/pow(10,14)==54)
- {
- printf("The card is a MasterCard's card\n");
- }
- else if (cc_number/pow(10,14)==55)
- {
- printf("The card is a MasterCard's card\n");
- }
- else if (cc_number/pow(10,15)==4)
- {
- printf("The card is a Visa's card\n");
- }
- else if (cc_number/pow(10,14)==4)
- {
- printf("The card is a Visa's card\n");
- }
- else if (cc_number/pow(10,13)==4)
- {
- printf("The card is a Visa's card\n");
- }
- else if (cc_number/pow(10,12)==4)
- {
- printf("The card is a Visa's card\n");
- }
- else
- {
- printf("The card is fake...\n");
- }
- }
- else
- {
- printf("The card is invalid...\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement