TCS NQT Previous Years Coding Questions

 TCS NQT Previous Years Coding Questions

 

 

Q1. Consider the below series:
1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17, ...
This series is a mixture of 2 series –all the odd terms in this series form a Fibonacci series and all th      even terms are the prime numbers in ascending order. Write a program tofind the Nth term in th         series. 

The value N is 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 Nth term, no other characters/strings or message should be written to STDOUT. For example, when N = 14, the 14th term in the series is 17. So
only the value 17 should be printed to STDOUT.


Q2. Given a series whose even term creates a separate geometric series and odd term creates another geometric series. Write a program to generate such series.
For example, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16,......

 

Q3. Find the 15th term of the series?
0,0,7,6,14,12,21,18, 28
Explanation :     In this series the odd term is increment of 7 {0, 7, 14, 21, 28, 35 – – – – – – }
        And even term is a increment of 6 {0, 6, 12, 18, 24, 30 – – – – – – } 



Q4. Consider the following series:

1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243, 64, 729, 128, 2187 …
This series is a mixture of 2 series – all the odd terms in this series form a geometric series and all the even terms form yet
another geometric series. Write a program to find the Nth term in the 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 value of n th term,no other character / string or message should be written to STDOUT. For example , if N=16, the 16th term in the series is 2187, so only value 2187 should be printed to STDOUT.
You can assume that N will not exceed 30.




Q5. 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,00


Comments

  1. Our DevOps Training in Noida incorporates *online classes, classroom sessions, real-life case studies, develop and deploy software using DevOps* and lots more.

    ReplyDelete

Post a Comment