Question: C programming exercise a) Create a C program that asks the user to enter the first 12 digits of an ISBN-13, and displays the corresponding

C programming exercise

a) Create a C program that asks the user to enter the first 12 digits of an ISBN-13, and displays the corresponding check digit.The program, however, is allowed to call the scanf(...) function only once. A sample interaction is shown below:

Enter the first twelve digits of ISBN-13: 978030640615

Check digit: 7

Hint: To read single digits, well use scanf with the %1d conversion specification.

Objective: Understanding expressions An International Standard Book Number (ISBN) is a unique number assigned to each book. ISBN-13 has thirteen digits in 5 parts which the last digit is check digit. The check digit is base ten, and can be 0-9. To compute a missing check digit, each digit, from the left to right, is alternatively multiplied by 1 or 3. Then, the sum of these products should be divided by 10 to find the remainder ranging from 0 to 9. Finally, the check digit can be found by subtracting the remainder from 10, that leaves a result from 1 to 10.

For example, take the ISBN 978-0-306-40615-? :

First calculate sum of products: 91 + 73 + 81 + 03 + 31 + 03 + 61 + 43 + 01 + 63 + 11 + 53 = 93

Remainder upon dividing by 10 is 3.

Remainder is subtracted from 10. d) Check digit is 7 (10 - 3).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!