Question
Write a C program with the code given that satisfies the following characteristics (1-4) and is able to verify card numbers: For this project, you
Write a C program with the code given that satisfies the following characteristics (1-4) and is able to verify card numbers:
For this project, you will implement a function that validates Visa credit card numbers. The function will take an unsigned long long int and return an int. A file is provided for you to complete. You only need to implement the function. You must match the function prototype given. You will receive a 0 if your function implementation does not match the given prototype. Do not add any global variables.
A valid Visa credit card has the following properties:
- starts with a 4
- is 16 digits long
- the Luhn algorithm results in a value that is a multiple of 10 (value % 10 = 0)
Here is a description of the Luhn algorithm using the number 4388576018402626.
- Starting with the rightmost digit, add every other digit.
6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38
- Double every other digit starting with the second digit from the right. If doubling of a digit results in a two-digit number, add the two digits to get a single-digit number.
2 * 2 = 4
2 * 2 = 4
4 * 2 = 8
1 * 2 = 2
6 * 2 = 12 (1 + 2 = 3)
5 * 2 = 10 (1 + 0 = 1)
8 * 2 = 16 (1 + 6 = 7)
4 * 2 = 8
Add all the single digit numbers.
4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37
- Sum the results from Steps 2 and 3.
38 + 37 = 75
- If the result from step 3 is divisible by 10, the credit card number is valid. Otherwise the number is invalid.
PreviousNext
int isValidCc (unsigned long long int CCNumber) int main) unsigned long long int cCNumbers[- 4388576018410707ULL, // valid 4388576018402626ULL, 1/ invalid 7388576018402686ULL, // invalid 438857601810707ULL, // invalid 4012888888881881ULL /7 valid yi for (int i - 0; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started