#include <iostream>
using namespace std;
void main()
{
long x;
cout<<"Please enter a credit card number: ";
cin>>x;
cout<<"You entered the number "<<x<<endl;
long num[17];
int i;
for (i=0; i<x; i++)
{
num [i];
}
cout<<num[i]<<endl;
long valid (num[i]);
{
int total;
int odd;
int even;
even = (num[1] + num[3]+ num[5] + num[7] + num[9] + num[11] + num[13] + num[15]);
odd = (num[0] + num[2] + num[4] + num[6] + num[8] + num[10] + num[12] + num[14]);
odd = odd*2;
if (num[0]||num[2]||num[4]||num[6]||num[8]||num[10]||num[12]||num[14]>4)
{
odd=odd++;
}
total = odd + even;
total = total + num[16];
if (total%10 == 0)
{
cout<<"This is a valid credit card :) "<<endl;
}
else
{
cout<<"This is NOT a valid credit card! "<<endl;
}
}
valid;
}
Sorry for the really bad paste job!
Thanks,
Cristy

New Topic/Question
This topic is locked



MultiQuote









|