Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.12 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<cs50.h>
  4.  
  5. int main (void)
  6. {
  7.    
  8.     int sum = 0;
  9.     int q;
  10.     int p;
  11.     long long cc_number;
  12.     int a;
  13.     do
  14.     {
  15.         printf("Enter your credit card number: ");
  16.         cc_number = get_long_long();
  17.     }while (cc_number <0);
  18.    
  19.     for (long long i=100; i<=pow(10,17); i=i*100)
  20.     {
  21.         q=(cc_number%i)*10/i ;
  22.         q=q*2;
  23.         if (q>9)
  24.         {
  25.             q = (q/10)+(q%10);
  26.         }
  27.        
  28.         sum = sum + q;
  29.     }
  30.     for(long long i=10; i<=pow(10,16); i=i*100)
  31.     {
  32.         p=(cc_number%i)*10/i;
  33.         sum = sum + p;
  34.     }
  35.     if(sum%10 ==0){
  36.         if(cc_number/pow(10,13) ==34)
  37.         {
  38.             printf("The card is an American Express' card\n");
  39.         }
  40.         else if(cc_number/pow(10,13)==37)
  41.         {
  42.              printf("The card is an American Express' card\n");
  43.         }
  44.         else if (cc_number/pow(10,14)==51)
  45.         {
  46.             printf("The card is a MasterCard's card\n");
  47.         }
  48.         else if (cc_number/pow(10,14)==52)
  49.         {
  50.             printf("The card is a MasterCard's card\n");
  51.         }
  52.         else if (cc_number/pow(10,14)==53)
  53.         {
  54.             printf("The card is a MasterCard's card\n");
  55.         }
  56.         else if (cc_number/pow(10,14)==54)
  57.         {
  58.             printf("The card is a MasterCard's card\n");
  59.         }
  60.         else if (cc_number/pow(10,14)==55)
  61.         {
  62.             printf("The card is a MasterCard's card\n");
  63.         }
  64.         else if (cc_number/pow(10,15)==4)
  65.         {
  66.             printf("The card is a Visa's card\n");
  67.         }
  68.          else if (cc_number/pow(10,14)==4)
  69.         {
  70.             printf("The card is a Visa's card\n");
  71.         }
  72.          else if (cc_number/pow(10,13)==4)
  73.         {
  74.             printf("The card is a Visa's card\n");
  75.         }
  76.          else if (cc_number/pow(10,12)==4)
  77.         {
  78.             printf("The card is a Visa's card\n");
  79.         }
  80.         else
  81.         {
  82.             printf("The card is fake...\n");
  83.         }
  84.     }
  85.     else
  86.     {
  87.             printf("The card is invalid...\n");
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement