Coders Packet

Credit-card Validation using C++

By kumari Ayushi Sinha

The Credit Card Validation program is written in the C++ language. It uses Luhn's Algorithm to validate the entered card number.

The Credit Card Validation program checks whether the user’s credit card number is valid or not using Luhn's algorithm.

The program has been implemented using the concept of classes and functions in C++.

According to Luhn Algorithm, it first doubles the even digit numbers starting from the end of the array. If this results in a number greater than 9, the sum of the resultant digits is found.

Next, it finds the sum of all the odd digit numbers starting from the end of the array.

The total sum of odd and even places is then calculated.

If the total sum is perfectly divisible by 10, it validates the credit card number to be correct.

 

The program uses two functions:

1. void type(): To determine whether the card is a Master card, Visa, American Express, or some other card.

2. void isValid(): To determine whether the entered card number is valid or invalid.

The program first determines the type of credit card and then validates it.

 

 

Download Complete Code

Comments

No comments yet