TCS Important Programs by Topic
1. Basic Programming (Control Structures)
• Sum of digits of a number
• Reverse a number
• Check palindrome number
• Check Armstrong number
• Factorial of a number (Iterative & Recursive)
• Fibonacci series (Iterative & Recursive)
• Prime number check
• Print all primes in a range
• LCM & GCD of two numbers (Euclidean method)
• Power of a number without using pow()
• Count number of digits in a number
2. Pattern Printing (Very Common in TCS NQT)
• Star pyramid
• Inverted star pyramid
• Diamond pattern
• Floyd’s triangle
• Pascal’s triangle
• Number pyramid
• Hollow square and hollow diamond
3. Strings
• Reverse a string without using inbuilt functions
• Check if a string is palindrome
• Count vowels, consonants, digits, and special characters
• Remove all duplicates from a string
• Find the frequency of each character in a string
• Remove all vowels from a string
• Convert string to uppercase/lowercase manually
• Check if two strings are anagrams
• Find the first non-repeating character in a string
4. Arrays
• Find the largest and smallest element in an array
• Second largest and second smallest in array
• Reverse an array
• Check if array is sorted
• Rotate array (left and right rotation)
• Count frequency of each element in array
• Find duplicate elements in array
• Remove duplicates from array
• Find missing number in 1 to N sequence
• Kadane’s Algorithm (Maximum Subarray Sum)
5. Matrix Programs
• Print matrix in row/column order
• Transpose of a matrix
• Check if matrix is symmetric
• Sum of all elements in matrix
• Sum of diagonal elements (primary and secondary)
• Rotate matrix 90° clockwise
• Spiral order matrix traversal
• Search element in 2D matrix
6. Number Theory & Bitwise
• Check if a number is prime (optimized √n)
• Check if a number is perfect/strong number
• Convert decimal to binary and binary to decimal
• Count set bits in a number
• Swap two numbers without using a third variable
• Find power of two closest to a number
7. Recursion & Backtracking
• Factorial using recursion
• Fibonacci using recursion
• Sum of digits using recursion
• Generate all subsets of a string
• N-Queens Problem
• Sudoku Solver (for Digital-level TCS questions)
8. Sorting & Searching
• Implement Bubble Sort
• Implement Selection Sort
• Implement Insertion Sort
• Implement Merge Sort
• Implement Quick Sort
• Binary Search (iterative & recursive)
• Linear Search
9. Advanced / Coding Round (TCS Digital level)
• Leaders in an array (rightmost greater element)
• Stock buy & sell for max profit
• Longest Common Subsequence (LCS)
• Longest Increasing Subsequence (LIS)
• Knapsack Problem (0/1)
• Matrix Chain Multiplication
• Minimum steps to reach end of array (Jump Game)
• Rat in a Maze problem