0% found this document useful (0 votes)
7 views10 pages

coding part-5

TCS nqt coding questions

Uploaded by

ashutomar7014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

coding part-5

TCS nqt coding questions

Uploaded by

ashutomar7014
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

TCS CODING

QUESTION 21-25
QUESTION 21

Addition of two numbers a Twist


Using a method, pass two variables and find the sum of two numbers.
Test case:
Number 1 – 20
Number 2 – 20.38
Sum = 40.38
There were a total of 4 test cases. Once you compile 3 of them will be shown to you and 1
will be a hidden one. You have to display error message if numbers are not numeric
QUESTION - 22

Consider the below series :


0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8
This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is
derived from the previous term using the formula
(x/2)
Write a program to find the nth term in this series.The value n in a positive integer that should be read from STDIN the nth term
that is calculated by the program should be written to STDOUT. Other than the value of the nth term no other characters
/strings or message should be written to STDOUT.
For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th
term is (8/2)=4. Only the value 4 should be printed to STDOUT.
You can assume that the n will not exceed 20,000
QUESTION - 23

Problem Statement
Our hoary culture had several great persons since time immemorial and king vikramaditya’s nava
ratnas (nine gems) belongs to this ilk.They are named in the following shloka:
Among these, Varahamihira was an astrologer of eminence and his book Brihat Jataak is recokened
as the ultimate authority in astrology.
He was once talking with Amarasimha,another gem among the nava ratnas and the author of
Sanskrit thesaurus, Amarakosha.
Amarasimha wanted to know the final position of a person, who starts from the origin 0 0 and
travels per following scheme.
QUESTION - 23

Scheme
• He first turns and travels 10 units of distance
• His second turn is upward for 20 units
• Third turn is to the left for 30 units
• Fourth turn is the downward for 40 units
• Fifth turn is to the right(again) for 50 units
… And thus he travels, every time increasing the travel distance by 10 units
QUESTION - 23

Case 1: Input : 3
• Expected Output :-20 20
Case 2: Input: 4
• Expected Output: -20 -20
Case 3: Input : 5
• Expected Output : 30 -20
Case 4: Input : 7
• Expected Output : 90 -20
QUESTION - 24

Sweet Seventeen Problem Statement


Given a maximum of four digit to the base 17 (10 – A, 11 – B, 12 – C, 13 – D … 16 – G} as input, output
its decimal value.
Test Cases :Case 1
• Input – 1A
• Expected Output – 27
Case 2
• Input – 23GF
• Expected Output – 10980
QUESTION - 25

Oddly Even Problem Statement


Given a maximum of 100 digit numbers as input, find the difference between the sum of odd and even
position digits
Test Cases
Case 1
• Input: 4567
• Expected Output: 2
Explanation : Odd positions are 4 and 6 as they are pos: 1 and pos: 3, both have sum 10. Similarly, 5 and 7
are at even positions pos: 2 and pos: 4 with sum 12. Thus, difference is 12 – 10 = 2
QUESTION - 25

Case 2
• Input: 5476
• Expected Output: 2
Case 3
• Input: 9834698765123
• Expected Output: 1

You might also like