#include<stdio.h>
#include<conio.h>
int main()
{
char isbn[15];
int i, sum = 0;
printf("\nEnter 10 digit ISBN number : ");
gets_s(isbn);
for (i = 0; i <= 9; i++)
{
isbn[i] -= 48;/*Converting characters into numerals*/
sum = sum + ((i + 1)*isbn[i]);/*checking the condition of the ISBN validity*/
}
if (sum % 11)/*If not divisble by 11*/
puts("\nISBN number is wrong.");
else
puts("\nISBN number is valid.");
_getch();
return 0;
}
Ad
Chapter - 10: Strings
To uniquely identify a book a 10-digit ISBN number is used. The rightmost digit is checksum digit. This digit is determined from the other 9 digits using condition that d1 + 2d2 + 2d3 + ... + 10d10 must be a multiple of 11 (where di denotes the ith digit from the right). The checksum digit d1 can be any value from 0 to 10: the ISBN convention is to use the value X to denote 10. Write a program that receives a 10-digit integer, computes the checksum, and reports whether the ISBN number is correct or not.
Ad
Ad