luc070.c¶
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).
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta amitdutta4255@gmail.com |
| Date | 08 Feb 2026 |
| License | MIT License (See the LICENSE file for details) |
| Difficulty | Beginner (index: 0 / 10) |
Concepts¶
Beta Feature
This concept detection system is still in beta and may occasionally show incorrect or incomplete results.
- Array
Actions¶
You can print or save this file by opening Raw and using your browser.
Source Code¶
#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;
}
Explanation¶
Explain with AI
Copy the prompt below and paste it into any AI assistant.
You are explaining a C programming code to a beginner.
STRICT RULES:
- Only use the given code. Do NOT assume anything not present.
- Do NOT add extra examples.
- Keep explanation clear and short.
- If something is unclear, say "Not clear from code".
- Follow the exact format below. Do NOT change headings.
FORMAT:
[START]
## What it does
(Explain the overall purpose in 1-2 sentences)
## Step-by-step
(Explain how the code works in steps, simple language)
## Key Concepts
(List concepts like loop, condition, function, etc.)
## Notes
(Mention any limitations, errors, or assumptions)
[END]
CODE (luc070.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;
}