ISRO CS C Output Questions: Trace Pointers, Arrays and Recursion Step by Step
Learn a repeatable trace-first method for C output problems. Three worked programs show copied pointers, array parameters and recursive output in exact execution order.
KnowledgeGate Team
Exam prep & CS education

Most C output questions are not solved by remembering one pointer rule in isolation. You must track the current object, pointer value, array mutations, copied parameters, and both phases of recursion in execution order. Under C17, a valid numerical trace exists only for defined behaviour; undefined or implementation-dependent traps require classification instead of a forced number.
Build one trace table before calculating any output
Before evaluating expressions, make a table with five columns:
Column | What to record |
|---|---|
Statement executed | Only the statement currently running |
Current frame |
|
Pointer or array target | The exact object, such as |
Value change | Old value, operation, and new value |
Output emitted | Text appended only when a |
Append output only when execution reaches a printf or similar call.
Keep these rules ready. a[i] means *(a + i). An array expression usually decays to a pointer to its first element, except as the operand of sizeof or unary &. A function receives a copied pointer. Pointer arithmetic is meaningful only within the same array object or one position past it. Each recursive call has its own frame.
Solve in one order: mark initial values, parenthesise dereference and increment expressions, trace mutations, draw calls, then concatenate output. Use Pointers in C for GATE to refresh memory diagrams, address arithmetic, and pointer-function basics. For loops and complexity counting, switch to Coding Questions for GATE CS. ISRO C output practice requires four narrower checks: alias targets, array-parameter decay, recursive print order, and C17 sequencing.
Worked trace: a copied pointer mutates the caller's array
Consider this fully defined C17 program:
#include <stdio.h>
void step(int *p) {
p[1] += *p;
p++;
printf("%d ", *p);
}
int main(void) {
int a[] = {2, 4, 6, 8};
int *p = a + 1;
step(p);
printf("%d %d %d\n", a[1], a[2], *(p + 2));
return 0;
}In main, p points to a[1], whose value is 4. The copied parameter in step points to the same element. Thus p[1] names a[2], while *p is 4. Since 6 + 4 = 10, a[2] changes from 6 to 10.
The local p++ moves the copy to a[2], and the first printf emits 10 . The caller's p still points to a[1]. Back in main, the expressions give a[1] = 4, a[2] = 10, and *(p + 2) = a[3] = 8. The complete output is:
10 4 10 8Copying a pointer does not copy the pointed-to array. Incrementing that copied pointer also does not rebind the caller's pointer.
![Memory diagram of a[0] to a[3] holding 2, 4, 6, 8, where step's copied pointer turns a[2] from 6 into 10 and then prints 10.](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1784565156831_z4t9u4.jpg)
Array decay changes the parameter type, not the caller's storage
This second program isolates array decay and local pointer rebinding:
#include <stdio.h>
void bump(int a[], int n) {
a[0] += n;
a = a + 1;
a[0] *= 2;
}
int main(void) {
int a[] = {1, 3, 5};
bump(a, 2);
printf("%d %d %d\n", a[0], a[1], a[2]);
return 0;
}Inside bump, a[0] += 2 changes the caller's first element from 1 to 3. The local parameter advances, so its new a[0] refers to the caller's original a[1]. Then 3 * 2 = 6. The array becomes {3, 6, 5}, and the output is 3 6 5.
In a parameter, int a[] is adjusted to int *a; it does not convey the array length. Therefore sizeof(a) inside bump is pointer size, not the caller's array size. A numerical answer that assumes an unstated pointer width is not portable.
Recursion produces output while descending and unwinding
Now combine a moving pointer with separate recursive frames:
#include <stdio.h>
void walk(const int *p, int n) {
if (n == 0) return;
printf("%d ", *p);
walk(p + 1, n - 1);
printf("%d ", *p);
}
int main(void) {
int a[] = {3, 1, 4};
walk(a, 3);
putchar('\n');
return 0;
}Keep every call on a separate row:
Frame | Stored |
| Action before next call |
|---|---|---|---|
|
| 3 | Print 3 |
|
| 2 | Print 1 |
|
| 1 | Print 4 |
| One-past pointer | 0 | Return without dereferencing |
Descent emits 3 1 4. After the base case, saved frames resume in reverse order, so the second calls emit 4 1 3. The exact output is 3 1 4 4 1 3.
Write each frame's p and n, mark the base case, read pre-call prints downward, then post-call prints upward.

Traps where ordinary tracing cannot give a valid number
Precedence first. Given int a[] = {7, 9}; int *p = a;, these separate calls print 7 9:
printf("%d ", *p++);
printf("%d", *p);That is because *p++ means *(p++). It prints the current value 7, then advances p to the element holding 9. After resetting p = a, these calls print 7 8:
printf("%d ", (*p)++);
printf("%d", *p);Here the pointer stays on a[0], while the pointed-to value changes from 7 to 8.
Do not force a number from this C17 expression:
int i = 1;
printf("%d %d", i++, ++i);Its behaviour is undefined because the same scalar is modified without sequencing. A compiler run cannot make it portable. Distinguish this from an unspecified result or implementation-dependent value when no C version or machine model is given.
Three more common mistakes are dereferencing a + length, even though forming that one-past pointer is allowed, treating a function's local pointer increment as a caller-side rebind, and ignoring statements after a recursive call during unwinding.
Use official ISRO material and recheck it every cycle
ISRO's current-opportunities page is the authority for active recruitment notices. Its official 2025 ICRB Computer Science recruitment archive links previous Computer Science question-paper material. Always recheck the notice and paper for your own cycle instead of assuming a fixed C question count, weightage, marking rule, or syllabus.
Use three official-paper practice buckets: compute a defined output, identify why no portable output exists, and trace calls or mutations across frames. These are study labels, not a permanent ISRO section structure.
For a timed attempt, spend about 20 seconds marking declarations and aliases. Build the trace row by row. Before calculating, test for undefined or implementation-dependent behaviour. Then compare your output with the options. For exam-focused preparation, use the ISRO Scientist/Engineer SC (CS) course alongside the ISRO preparation category.
Practise with a ten-question ladder
Build a ten-question ladder: three pointer-precedence questions, three array-decay or function questions, three recursion-order questions, and one undefined-behaviour question. For every defined program, write the trace before running it. Use a C17 compiler only afterward to check your manually derived result.
Track objects, not merely variable names.
Treat function pointer parameters as copied aliases.
Split recursion at the base case.
Refuse a forced number for undefined code or code that depends on an unstated machine.
KnowledgeGate has more than 300 available practice questions across these C areas, spanning C in general rather than ISRO papers alone. Use the C Programming course to repair language fundamentals, then return to the ISRO track and repeat the ten-question set until the trace table becomes automatic.
Keep learning
C Programming Mixed-Concept Questions Explained: Arrays, Pointers, Functions and Output Tracing
Learn a four-pass method for tracing C programs that combine arrays, pointer aliases, function calls, static storage and side effects, with a complete worked output trace.
Relationship Between Arrays and Pointers in C: Decay, Address Arithmetic and a Worked Memory Trace
See why an array is not a pointer, even when their displayed addresses match. Trace decay, pointer movement, sizeof, function parameters and bounds through one C array.
ISRO CS Operating Systems PYQ Patterns: Scheduling, Memory and Deadlock Worked Step by Step
Learn four scratch-work methods for ISRO-style Operating Systems problems. Follow complete Round Robin, paging, LRU, semaphore and deadlock safety traces.
Recursion with Pointers in C: Concepts, Traces and Worked Examples
Learn how local pointer copies interact with shared array memory, then trace one mutating sum and one reverse-print function from descent to unwind.





