TCS Coding Questions and Answers (Latest) 2018 | FACE Prep

TCS Coding Questions and Answers (Latest) 2018 | FACE Prep

TCS Coding Questions & Answers | Latest Coding Problems

Introduction

Cracking the TCS National Qualifier Test (NQT) requires strong problem-solving skills, especially in the Coding Section under IT Programming. This section tests a candidate’s proficiency in logical reasoning, programming fundamentals, and coding efficiency.

This guide provides a detailed overview of the TCS NQT Coding Section Pattern, along with some of the most frequently asked TCS coding questions and their solutions.


TCS Coding Section Pattern

The Coding section follows a structured format:

  • Number of Questions: 2
  • Time Limit: 45 minutes
  • Allowed Languages: C, C++, Java, Python, PERL

Tips to Crack the Coding Section

  • Master fundamental programming concepts.
  • Focus on data structures, algorithms, and logical reasoning.
  • Ensure that your solution passes all possible test cases.
  • Practice writing optimized code to enhance efficiency.

TCS NQT Coding Questions and Solutions

Question 1: Sweet Seventeen

Problem Statement:

Convert a four-digit number in base 17 (where 10 = A, 11 = B, 12 = C, …, 16 = G) to its decimal equivalent.

Example:

Input: 23GF

Expected Output: Decimal equivalent of 23GF


Question 2: A Sober Walk

Problem Statement:

A person starts from the origin (0,0) and moves in a specific pattern:

  1. Right by 10 units
  2. Up by 20 units
  3. Left by 30 units
  4. Down by 40 units
  5. Right by 50 units
  6. …and so on

Find the final position after n moves.

Constraints:

2 <= n <= 1000

Example:

Input: 3

Expected Output: Final coordinates after 3 moves.


Question 3: Word is the Key

Problem Statement:

Check if a given word is a reserved keyword in a programming language.

Keywords List:

break, case, continue, default, defer, else, for, func, goto, if, map, range, return, struct, type, var

Example:

Input: defer

Output: defer is a keyword


Question 4: Jar of Candies

Problem Statement:

A jar contains N candies. If the number of candies left reaches K, it is refilled.

Example:
Input: 3

Output:

Number of Candies Sold: 3
Number of Candies available: 7

Question 5: Oxygen Value

Problem Statement:

Three trainees participate in a fitness test. Their oxygen levels are recorded after three rounds. Identify the fittest trainee based on average oxygen levels.

Constraints:

  • Oxygen values should be between 1 - 100.
  • If all average oxygen values are below 70, print “All trainees are unfit”.

Example:

Input:

95 92 95
92 90 92
90 92 90

Output:

Trainee Number: 1
Trainee Number: 3

Question 6: To Zero or Not Zero

Problem Statement:

Given a range m to n, print numbers with leading zeroes.

Example:

Input: 5 10

Expected Output: 05 06 07 08 09 10


Question 7: Oddly Even

Problem Statement:

Given a number (up to 100 digits), compute the difference between the sum of odd-positioned and even-positioned digits.

Example:

Input: 4567

Output: 2


Question 8: Minting Mints

Problem Statement:

A queue of children is given mints. Each child (except the first) has one mint less than the sum of all children before them.

Constraints:

  • 2 < n < 10
  • 1 < len < 20

Example:

Input: 4 2

Output: 7


Conclusion

Mastering these coding problems will significantly improve your chances of clearing the TCS NQT Coding Section. Focus on practicing similar data structures and algorithm problems to enhance your problem-solving skills.

TCS Coding Questions & Answers | Latest Coding Problems

c