Selvan asks his friend Arav to buy the book. Arav would recommend a bookstall in Thanjavur. Arav further says that the advice given to Selvan is to have the number ISBN when buying the book. Selvan doesn’t know what it is. Arav tells him that. You must have notices every book has a 10 digit series of number.
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, 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 a value equal to 10; this is done by writing it as ‘X’.
Functional Description:
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:
The line with an integer indicates the number of books
The second input as a character for ISDN number
Output:
Print as “Valid” or “Invalid” based on the ISBN value given as input.
#include <stdio.h> int isISBN(char isbn[]); int main() { int t,i; char isbn[20]; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%s",isbn); if(isISBN(isbn)){printf("Valid\n");} else{printf("Invalid\n");} } return 0; } int isISBN(char isbn[]) { int i=0,c=0; for(i=10;i>=1;i--) { if(isbn[10-i]=='X'){c=c+10;break;} else{ c=c+(i * (isbn[10-i]-'0'));} } if(c%11==0){return 1;} else{return 0;} }
INPUT_1:
1
00750142X612
OUTPUT:
Invalid
INPUT_2:
3
007462542X
007562642X
018462553X
OUTPUT:
Valid
Valid
Valid
ILLUSTRATION
Morae! Q
- Find a triplet such that triplet is minimum of all the triplets.
- Rearrange characters in a string such that no two adjacent are same.
- Return the coordinates of all cells in matrix sorted by their distance.
- Function to verify the ISBN number from the book.
- Find out the absolute difference of values of two array integers.
- Rotate the array in the right direction by K steps.
- Find the sequence of moves that wins the game, collect exactly G coins!.
- Calculate the sum of boundary elements of a matrix.
- Find the total number of ways to reach the tree house.
- Compute profit and loss of a product.
- Find the total expense of purchased items.
- Determine the maximum sequence weight.
- Find the person’s birth year is a leap year or not.
- Find the inner rating with the displayed rating.
- Find if angles are valid to form a triangle.
- Find out the winner of the game from the given statistics.
- Verify the tag to determine if one needs to arrest or allow the vehicle.
- Find the largest hexadecimal number.
- Group up all anagrams together from given words.
- Return all anagrams from the given words.