An ISBN (International Standard Book Number) is a 10 digit number that is used to identify a book.
The first nine digits of the ISBN number are used to represent the Title, Publisher and Group of the book and the last digit is used for checking whether ISBN is correct or not.
The first 9 digits of it, can take any value between 0 and 9, but the last digits, sometimes may take value equal to 10; this is done by writing it as ‘X’.
To verify an ISBN, calculate 10 times the first digit, plus 9 times the second digit, plus 8 times the third digit and so on until we add 1 time the last digit. If the final number leaves no remainder when divided by 11, the code is a valid ISBN.
Input : 007462542X Output : Valid 007462542X = 10*0 + 9*0 + 8*7 + 7*4 + 6*6 + 5*2 + 4*5 + 3*4 + 2*2 + 1*10 = 176 Since 55 leaves no remainder when divided by 11, hence it is a valid ISBN. Input : 0112112425 Output : Invalid 0112112425 = 10*0 + 9*1 + 8*1 + 7*2 + 6*1 + 5*1 + 4*1 + 3*4 + 2*2 + 1*5 = 71 Since 71 is not divisible by 11, given number is not a valid ISBN.
Now, we design a program to accept a ten digit code from the user and then we will check whether a number is ISBN or not. Display an appropriate message.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- A Program to check if strings are rotations of each other or not
- Program to check if a date is valid or not
- Java program to check palindrome (using library methods)
- Program to check Strong Number
- Program to check if a given year is leap year
- Program to check if two given matrices are identical
- C Program to Check if a Given String is Palindrome
- Program to check if a given number is Lucky (all digits are different)
- Python program to check if a string is palindrome or not
- Program to check if input is an integer or a string
- Program to check whether the given number is Buzz Number or not
- Program to check Strength of Password
- Program to check for Peterson number
- Program to check if a number is Positive, Negative, Odd, Even, Zero
- Program to check if matrix is upper triangular
- Program to check if a number belongs to a particular base or not
- Program to check if tank will overflow, underflow or filled in given time
- Program to check if matrix is lower triangular
- Program to check for a Valid IMEI Number
- Program to check Plus Perfect Number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.