Professional Documents
Culture Documents
Assignment 2: ISSN: Example 1: Partial ISSN Is 0316406
Assignment 2: ISSN: Example 1: Partial ISSN Is 0316406
Department of Computer Science and Engineering, The Chinese University of Hong Kong
Assignment 2: ISSN
Due: 20:00, Wed 13 Feb 2019 Full marks: 100
Introduction
The objective of this assignment is to learn how to use variables, operators, expressions, and console
input/output. Name your source file name as issn.c.
The International Standard Serial Number (ISSN) is a number to uniquely identify a serial publication
like magazines, journals, comic books, etc. (ISSN is similar in concept to ISBN but the latter is
assigned to books instead.) ISSNs are 8-digit long, in which the rightmost digit is a check digit. It is
used for simple error detection, and to protect against accidental errors such as a mistyped digit or
the permutation of two successive digits. In this assignment, you will write a program to obtain a 7-
digit partial ISSN (without the check digit) and compute the corresponding check digit to complete
the ISSN.
1. Compute the weighted sum 𝑆 = 8𝑑1 + 7𝑑2 + 6𝑑3 + 5𝑑4 + 4𝑑5 + 3𝑑6 + 2𝑑7 .
2. Find the remainder 𝑟 of 𝑆 when divided by 11, i.e., 𝑟 = 𝑆 mod 11.
3. Subtract the remainder 𝑟 from 11. The result is the check digit: 𝑑8 = 11 − 𝑟. However, if the
subtraction result is 11, then change 𝑑8 to 0. If the result is 10, then change 𝑑8 to X (Roman
numeral ten).
1. 𝑆 = 8 × 0 + 7 × 3 + 6 × 1 + 5 × 6 + 4 × 4 + 3 × 0 + 2 × 6 = 85
2. Remainder 𝑟 = 85 mod 11 = 8.
3. Finally, 𝑑8 = 11 − 𝑟 = 11 − 8 = 3. Thus the complete ISSN is 03164063.
1. 𝑆 = 8 × 7 + 7 × 5 + 6 × 3 + 5 × 4 + 4 × 2 + 3 × 6 + 2 × 0 = 155
2. Remainder 𝑟 = 155 mod 11 = 1.
3. Finally, 𝑑8 = 11 − 𝑟 = 11 − 1 = 10, and 10 has to be changed to X. Thus the complete ISSN is
7534260X.
Program Specification
The program should obtain a partial 7-digit ISSN as user input. You can assume that the user input is
always a 7-digit integer. (That is, you do not have to check whether the input is out of this
assumption.) Then apply the above method to compute the check digit of the input and display the
complete ISSN, which should be printed in two segments in the format NNNN-NNNN.
Sample Run
In the following sample runs, the blue text is user input and the other text is the program printout.
You can try the provided sample program for other input. Your program output should be exactly the
same as the sample program (same text, symbols, letter case, spacings, etc.). Note that there is a
space after the ‘:’ in the program printout.