# Verify ISBN….[Cprogm] FcukTheCode

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