Wednesday, April 30, 2025

TCS Coding Round Interview Questions sample

 

TCS Coding Round Interview Questions

TCS (Tata Consultancy Services) coding round typically assesses your problem-solving skills and programming fundamentals. Here are some common types of questions you might encounter:

Common Question Types

  1. Basic Programming Problems

    • Fibonacci series

    • Prime number checking

    • Palindrome checks (numbers or strings)

    • Factorial calculation

    • Armstrong number verification

  2. Array Manipulation

    • Finding largest/smallest element

    • Sorting arrays

    • Matrix operations (transpose, addition)

    • Searching elements

  3. String Operations

    • String reversal

    • Vowel/consonant counting

    • Anagram checking

    • Removing duplicates from strings

  4. Mathematical Problems

    • GCD/LCM calculation

    • Decimal to binary conversion

    • Perfect number checking

    • Sum of digits

Sample Questions with Solutions

1. Fibonacci Series

python
Copy
Download
n = int(input("Enter number of terms: "))
a, b = 0, 1
for _ in range(n):
    print(a, end=' ')
    a, b = b, a+b

2. Prime Number Check

python
Copy
Download
num = int(input("Enter a number: "))
if num > 1:
    for i in range(2, int(num**0.5)+1):
        if num % i == 0:
            print("Not prime")
            break
    else:
        print("Prime")
else:
    print("Not prime")

3. String Palindrome

python
Copy
Download
s = input("Enter a string: ")
if s == s[::-1]:
    print("Palindrome")
else:
    print("Not palindrome")

4. Array Sorting (Bubble Sort)

python
Copy
Download
arr = list(map(int, input("Enter array elements: ").split()))
n = len(arr)
for i in range(n-1):
    for j in range(n-i-1):
        if arr[j] > arr[j+1]:
            arr[j], arr[j+1] = arr[j+1], arr[j]
print("Sorted array:", arr)

Tips for TCS Coding Round

  1. Focus on basic programming concepts

  2. Practice time management (typically 30-45 minutes per question)

  3. Pay attention to edge cases

  4. Write clean, readable code with proper indentation

  5. Comment your code where necessary

  6. Test your code with sample inputs before submission

No comments:

Post a Comment