Question
The Code below is correct however it will either print the check digit x under the number using the second examples numbers or with the
The Code below is correct however it will either print the check digit x under the number using the second examples numbers or with the first example it will print 0378-5955 im not sure why it is adding that symbol in there.... it needs to match the examples exact!
#include
#include
int main()
{
int sum = 0, check_digit = 0;
char input[8];
//Printing/Adding The ISBN:
printf("Enter The 7 Digit ISSN In Form Of XXXX-XXX ");
scanf("%s", input);
//Repeat Function Over Each Digits Of ISBN:
int i = 0, j = 0;
for (; i
//If The Numbers Are 4 or "-" Disregard And Find The Answer From Formula For Digits:
if(i != 4){
sum += (input[i] - '0') * (8 - j);
j++;}}
//Find Check Digit:
check_digit = 11 - sum % 11;
//If Check Digit Is 10 Add X:
printf("The Complete 8 Digit ISSN Including Check Digit Is ");
if (check_digit == 10){
printf("%sx", input);}
//Add Check Digit To The End:
else{
printf("%s%d\t", input, check_digit);}
return 0;
International Standard Serial Number (ISSN) is identified by its eight-digit used to uniquely identify a serial publication, such as a newspaper. The ISSN is an eight-digit number that is split into two four-digit numbers by a hyphen. A check digit is the final digit, which might be a 0 through 9 or an X (if check digit=10). For example, the ISSN of the journal Hearing Research, is 0378-5955 where 5 is the check digit. To find the check digit the following algorithm is used: 1. Sum of the first seven digits of ISSN multiplied by 8,7,6,5,4,3, and 2 , respectively: for example. 08+37+76+85+54+93+52=160 2. The modulus 11 of this sum is then calculated 160mod11=6. 3. This modulus value is then subtracted from 11 to give the check digit:11 - 6=5 4. the value of check digit can be from 0 to 9 and X. where X is representing the number 10. Write a C program that input the first 7 digits of ISSN of format 0378-595 using scanf function as one input statement (you are not allowed to use more than one scanf) then breakdown your input and find the check digit as explained above. If the result of check digit is 10 replace it with x Here 2 example that you can check your solution //0378-5955 (check digit is 5) //2434-561X (check digit is 10 replaced by X) Enter the 7 digit ISSN in form of XXXXXXCX : 0378-595 The complete 8 digit ISSN including check digit is [0378-5955] Enter the 7 digit ISSN in form of XXCX-XXC: 2434-561 The complete 8 digit ISSN including check digit is [ 2434-561X ]Step 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