luc070.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 08 Feb 2026
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Write a program that receives a 10-digit ISBN number, computes the checksum (d1 + 2d2 + 3d3 + ... + 10d10), and reports whether the ISBN number is correct (sum divisible by 11).
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char isbn[15];
int i, sum = 0, digit;
printf("Enter 10-digit ISBN number: ");
scanf("%s", isbn);
/* The formula given is: d1 + 2d2 + 3d3 + ... + 10d10
where di is the ith digit from the RIGHT.
If input is "007462542X" (Length 10):
isbn[0] is d10 (Weight 10)
isbn[1] is d9 (Weight 9)
...
isbn[9] is d1 (Weight 1)
*/
for (i = 0; i < 10; i++)
{
// Handle 'X' which represents 10 in ISBN
if (isbn[i] == 'X' || isbn[i] == 'x')
digit = 10;
else
digit = isbn[i] - '0';
// Weight is (10 - i)
sum += digit * (10 - i);
}
printf("Calculated Checksum: %d\n", sum);
if (sum % 11 == 0)
printf("The ISBN number is Correct.\n");
else
printf("The ISBN number is Incorrect.\n");
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43