·Engineering·Easy·20 min

TCS NQT Programming Logic: Trace-the-Output Pseudocode and Flowchart Round (Ninja, India)

20 min · 1 credit · scorecard at the end
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.

  1. 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 = 0
    Example 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.
  2. 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 1
    Example 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.
Reference

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.

Line-by-line Trace Discipline
Narrates the variable state per iteration before stating any output.
28%
Recursion And Call-stack Reasoning
Finds the base case and counts calls correctly, separating count from return value.
18%
Array And Index Edge Handling
Tracks index against bound and flags empty and last-position edges.
18%
Time Complexity Justification
Derives Big O from loop nesting rather than reciting a memorised value.
14%
Concept Precision Under Pace
Answers value-versus-reference and OOP-pillar items in one precise line.
12%
Composure On The Twist
Re-traces affected lines on a twist instead of re-guessing the answer.
10%

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

What is the TCS NQT Programming Logic section?
It is the code-reasoning block of the TCS NQT, with about 10 questions in 15 minutes. You read short snippets and predict behaviour rather than writing code from scratch. Topics include loops, recursion and iteration, arrays, time complexity and OOPs concepts, and there is no negative marking.
Do I have to write code in this round?
No. This is a trace-the-output round. You read a five-to-eight-line pseudocode snippet or a flowchart and reason aloud about what it does. You narrate the variable state line by line and state the final output. Writing full programs from scratch belongs to the separate Advanced Coding section.
How is the TCS NQT exam structured in 2026?
The NQT is a single 190-minute session split into a mandatory Foundation Section of 75 minutes covering Numerical Ability, Verbal Ability and Reasoning Ability, and an Advanced Section of 115 minutes covering Advanced Quantitative and Reasoning plus Advanced Coding with two problems.
What topics does TCS NQT Programming Logic cover?
Data Types, Loops, Functions and Scope, Recursion and Iteration, Array, OOPs, Time Complexity, and Input and Output. Concept MCQs frequently test call by value versus call by reference, pointers, static variables, and the four pillars of object-oriented programming.
How do I trace a loop to predict the output?
Write a small variable-state table. List each variable as a column and each iteration as a row. After every pass, update the values, then check the loop condition before the next pass. The output is whatever the variables hold when the condition first becomes false.
What is the difference between call by value and call by reference?
Call by value copies the argument into the function, so changes inside the function do not affect the caller. Call by reference passes the address, so the function can change the caller's variable. A swap written with call by value will not swap the original variables.
How do I find the time complexity of a snippet?
Count how the work grows with the input size. A single loop over n items is linear or order n. A loop nested inside another loop, each running n times, is quadratic or order n squared. State the Big O class and justify it from the loop nesting, not from a memorised table.
Why do candidates fail the Programming Logic section?
The most common reasons are guessing before tracing, off-by-one errors on the loop bound, confusing prefix and postfix increment, mixing up call by value and call by reference, and freezing on a twist. Because scoring is by final output only, a single slip flips the answer to wrong.
How many questions and how much time in Programming Logic?
Candidates report about 10 questions in 15 minutes, which is roughly 90 seconds per item. You cannot trace exhaustively, so you must trace efficiently, confirm the loop termination and the recursion base case, and move on without second-guessing a clean trace.
Is the TCS NQT Ninja round good for non-CS branch students?
Yes, and this mock is built for them. The section is hardest for non-CS students because of the data-structure content, but tracing is a learnable skill. Practising the variable-state walk aloud closes most of the gap before you reach the real exam hall in India.
What is the twist the interviewer applies after a trace?
After you state an output, the panellist changes one small thing and asks what happens. Common twists are changing a strict less-than to less-than-or-equal, asking what an empty array does, or asking how many times a recursive function is actually called. The twist tests whether you traced or memorised.

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.