Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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.

  1. Starting with the rightmost digit, add every other digit.

6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38

  1. 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

  1. Sum the results from Steps 2 and 3.

38 + 37 = 75

  1. 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; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Power Bi And Azure Integrating Cloud Analytics For Scalable Solutions

Authors: Kiet Huynh

1st Edition

B0CMHKB85L, 979-8868959943

More Books

Students also viewed these Databases questions

Question

Discuss what theyre doing to be family friendly.

Answered: 1 week ago

Question

1. Identify six different types of history.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago