# TCS code vita questions

I had participated in TCS codevita 2014 and cracked the first round successfully but I was unable to crack 2nd round ,so drop out from the the contest. Following is one of the question asked in TCS CodeVita 2014 , sharing with you.
Problem Statement:

An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first 9 digits are used to represent the book and the 10th digit is used to ensure that the ISBN is correct. To validate the ISBN number, calculate a sum that is 10 times the first digit plus 9 times the second digit plus 8 times the third digit … all the way until you add 1 times the last digit. If the sum is divisible by 11, then the 10 digit code is a valid ISBN number.

For example 1111456291 is a valid ISBN, because

10*1 + 9*1 + 8*1 + 7*1 + 6*4 + 5*5 + 4*6 + 3*2 + 2*9 + 1*1 = 132 which is divisible by 11.

Each of the first nine digits can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten. This is done by writing the last digit as X.
For example, 156881111X is a valid ISBN, because

10*1 + 9*5 + 8*6 + 7*8 + 6*8 + 5*1 + 4*1 + 3*1 + 2*1 + 1*10 = 231 which is divisible by 11.

You have to write a program to fill in the missing digit from a given ISBN number where the missing digit is represented as ‘?’. The missing digit should be a value between 0 and 9 or ‘X’ (X represents 10)
Input Format

 Line 1 A single line with a ten digit ISBN number that contains ‘?’ in a single position. The length of the input should be 10 characters.

Output Format

The output should contain the missing digit.

The length of the output field defined in the program should be 1.

If a suitable value for ‘?’ cannot be found which makes the ISBN valid, then the text ‘NO SOLUTION POSSIBLE’

should be displayed  as output.

 Sample Input I Sample Input II Sample Input III Sample Input IV 15688?111X 493?568419 15@881111X X5688?1111 Sample Output I Sample Output II Sample Output III Sample Output IV 1 NOSOLUTION POSSIBLE INVALID INPUT INVALID INPUT

Note:

Please adhere to the input and output specifications given in the problem statement. Please note that the output “INVALID INPUT” AND “NO SOLUTION POSSIBLE” should be printed in the upper case.

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.

Participants submitting solutions in C language should not use functions from <conio.h> / <process.h> as these files do not exist in gcc

## Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.