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
Basic Programming Problems
Fibonacci series
Prime number checking
Palindrome checks (numbers or strings)
Factorial calculation
Armstrong number verification
Array Manipulation
Finding largest/smallest element
Sorting arrays
Matrix operations (transpose, addition)
Searching elements
String Operations
String reversal
Vowel/consonant counting
Anagram checking
Removing duplicates from strings
Mathematical Problems
GCD/LCM calculation
Decimal to binary conversion
Perfect number checking
Sum of digits
Sample Questions with Solutions
1. Fibonacci Series
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
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
s = input("Enter a string: ") if s == s[::-1]: print("Palindrome") else: print("Not palindrome")
4. Array Sorting (Bubble Sort)
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
Focus on basic programming concepts
Practice time management (typically 30-45 minutes per question)
Pay attention to edge cases
Write clean, readable code with proper indentation
Comment your code where necessary
Test your code with sample inputs before submission
No comments:
Post a Comment