TCS NQT Programming Logic: Trace-the-Output Pseudocode and Flowchart Round (Ninja, India)
- Field
- Engineering
- Company
- Tata Consultancy Services
- Role
- Assistant System Engineer Trainee (Ninja)
- Duration
- 20 min
- Difficulty
- Easy
- Completions
- New
- Updated
- 2026-06-11
How to prepare
What this round tests, what strong and weak answers sound like, and the traps to sidestep.
What this round is about
This is a mock of the TCS NQT Foundation Programming Logic block for the Assistant System Engineer Trainee (Ninja) track. In the real exam this section gives you roughly 10 questions in 15 minutes, and it is the part most students, especially from non-CS branches, find the hardest in the whole paper. The twist that catches people out is that you are not writing code here. You read a short five-to-eight-line pseudocode snippet or a flowchart and you reason about what it does. A panellist named Sneha shows you one snippet at a time on a card, asks you to trace the variable state aloud and state the final output, then changes one small thing and asks what happens. Doing this by voice forces the one habit a silent multiple-choice question never can: saying the value of each variable, line by line, before you commit to an answer.
What strong answers look like
A strong candidate slows down and narrates the walk. They keep a small running tally of the one or two variables that change, they say the value after each iteration, and they name the exact iteration where the loop condition first becomes false. On recursion they identify the base case first, then count how many times the function is actually called by walking the call stack. On an array snippet they track the index against the bound and immediately flag the empty-input and last-element edges. On a complexity item they name the Big O class and justify it from how the loops nest. On a concept item they answer in one precise line, for example that call by value copies the argument while call by reference shares the address. When the twist lands, they re-trace calmly rather than re-guessing.
What weak answers look like (and how to avoid them)
A weak answer is a bare number with no walk behind it. The classic slips are an off-by-one on the loop bound, confusing prefix and postfix increment, assuming a swap written by value changes the caller's variables, and freezing when the condition flips from less-than to less-than-or-equal. To avoid them, never say the output until you have said the variable values out loud, always check the loop termination once more before you answer, and on any twist go back to the tally instead of trusting your first instinct. If you are unsure, trace one more iteration rather than guessing; the extra ten seconds is cheaper than a wrong final output.
Pre-interview checklist (2 minutes before you start)
Have a blank sheet and a pen ready so you can keep a variable tally as you talk. Pick the one language you actually know, C, C plus plus, Java or Python, and decide you will read every snippet in that mental model rather than switching. Warm up by silently tracing a three-line counter loop and a two-line factorial so your hand and your voice are in sync. Remind yourself of the rule for this section: walk first, answer second. Sit somewhere quiet, because this is a spoken round and the panellist is listening for the trace, not just the result.
How the AI behaves
Sneha plays a real TCS NQT campus panellist. She opens warm to settle placement nerves, then gets exacting as the snippets get harder. She shows one card at a time and stops you the moment you jump to a final number, asking to hear the walk instead. She applies the same twists the real exam uses and she interrupts a guess. She never tells you the answer and never teaches a framework; she pulls the reasoning out of you. When you trace correctly she names the specific move that made it work rather than praising emptily. In the final stretch she shifts back to a coaching tone and leaves you with the one habit to carry into the real hall.
Common traps in this type of round
The biggest trap is treating this like a silent multiple-choice question and racing to the answer; the voice format exists precisely to expose that. Other traps are re-reading the snippet three times instead of keeping a tally, ignoring the empty-array and last-index edges, miscounting recursive calls because the base case was misread, and reciting a memorised time-complexity instead of justifying it from the loops. The deepest trap is panicking on the twist: when one symbol changes, candidates abandon the trace and guess again. Hold the tally, change only what the twist touches, and re-read the result off the variables.
Sample problems you'll face
The 2 problems below are the same ones you'll work through in the live session — no surprises. Read the constraints carefully; the AI persona will refer you to the on-canvas card by problem number.
- 1Predict the Output: While Loop with Accumulator
Trace this pseudocode and state the final printed value of sum. set sum = 0 set i = 1 while i < 5 set sum = sum + i set i = i + 1 end while print sum Walk the variable state for each iteration, then state the output. After you answer, the panellist will change the condition from i < 5 to i <= 5 and ask what the new output is.
Example inputLoop bound condition: i < 5 ; start i = 1, sum = 0Example outputVariable-state trace: after pass1 i=1 sum=1; after pass2 i=2 sum=3; after pass3 i=3 sum=6; after pass4 i=4 sum=10; check i=5 -> 5 < 5 is false, loop stops. Output: sum = 10. Twist (i <= 5): one extra pass adds 5, output sum = 15.- Pseudocode only; the candidate reads and traces, does not write code
- The loop variable i is an integer starting at 1
- Canvas instruction: step through the variable-state table row by row, writing i and sum after each iteration, and state the printed value of sum out loud before the panellist applies the less-than-or-equal twist.
- 2Trace the Recursion: Count the Calls in Factorial
Trace this pseudocode and state both the returned value and how many times the function fact is called when fact(4) runs. function fact(n) if n <= 1 then return 1 else return n * fact(n - 1) end if end function print fact(4) Identify the base case first, then count each call up the stack, then give the printed value. After you answer, the panellist will ask what changes if the empty case n equals 0 is passed.
Example inputCall: fact(4) ; base case: n <= 1 returns 1Example outputCall-stack trace: fact(4) -> 4 * fact(3) -> 3 * fact(2) -> 2 * fact(1); fact(1) hits the base case and returns 1. Calls entered: fact(4), fact(3), fact(2), fact(1) = 4 calls. Returned value unwinds: 1, then 2, then 6, then 24. Output: 24. Twist (fact(0)): n <= 1 is true at once, returns 1, only 1 call.- Pseudocode only; the candidate reads and traces, does not write code
- Keep the count of calls separate from the single value returned at the top of the stack
- Canvas instruction: draw the call stack line by line, marking each entry into fact and the value each call returns on the way back up, then state the call count and the printed output before the base-case-at-zero twist.
The full breakdown
How you're scored, the questions candidates ask most, and the research this interview is built on. Skim it — or just start the interview.
Interview framework
You will be scored on these 6 dimensions. The full rubric with definitions is below.
What we evaluate
Your final scorecard breaks down across these dimensions. The full rubric and tier criteria are revealed inside the interview itself.
- Variable State Tracing24%
- Recursion and Call-Stack Reasoning18%
- Array and Index Edge Handling18%
- Time Complexity Justification14%
- Concept MCQ Precision14%
- Composure Under Twist and Pace12%
Common questions
Sources this interview is built on
Real candidate-report URLs (Glassdoor / AmbitionBox / PrepInsta / GeeksforGeeks / Medium) reviewed when authoring the questions, persona, and rubric. Verify the realism yourself.
- TCS NQT 2026: Exam Pattern, Syllabus and Preparation Guide - GeeksforGeeksgeeksforgeeks.org
- TCS NQT Syllabus 2026 and Exam Pattern - PrepInstaprepinsta.com
- TCS NQT Programming Logic Questions - PrepInstaprepinsta.com
- TCS NQT Coding Questions 2026 with Answers and PYQs - Unstopunstop.com
- Top 60+ TCS NQT Interview Questions and Answers for 2026 - Simplilearnsimplilearn.com