/* * Author : Amit Dutta * Date : 08 Feb 2026 * Repo : https://github.com/notamitgamer/bsc * License : MIT License (See the LICENSE file for details) */ /* 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). */ /* Let Us C, Chap- 15 (Strings), Qn No.: C(b) */ /* This file is auto-generated by a bot. */ /* This code is not compiled; it is for reference only. */ #include #include #include 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; }