GATE 2020 C Programming Questions: Topic Split and Three Worked Traces
Trace three GATE 2020 C questions to 19, 55 and 81. Learn where pointer units, persistent static variables and bit order change the answer, then use the traces to guide revision.
KnowledgeGate Team
Exam prep & CS education

Pointer arithmetic and recursive state are easy to misread when a final value hides the intermediate steps. The GATE 2020 set contains three NAT questions: an array expression returns 19, a static-recursion program returns 55, and a bit loop returns 81. They form a sample, not an official subject-wise marks allocation or an exhaustive inventory of C questions.
GATE 2020 C questions: source and scope
The previous-papers page on IIT Bombay's GATE 2021 website lists the GATE 2020 Computer Science question paper and answer key. The archive supplies the paper and key; each question's main solving skill determines its topic label.
These three GATE-tagged C questions are numerical answer type (NAT), so there are no options to eliminate. Derive the output or return value. For broader study planning, use the GATE preparation resources.
Earlier GATE C topic maps serve broader inventories. The 2015 C topic map covers fourteen questions across five skill groups; the 2020 set isolates three NAT questions and derives 19, 55 and 81.
Topic-wise split of the three verified questions
Each row assigns one primary teaching topic, so the total remains three.
Primary teaching topic | Identifying expression | Count | Skill |
|---|---|---|---|
Arrays and pointers |
| 1 | Row-versus-element stepping |
Recursion and static storage |
| 1 | Persistent state |
Loops and binary representation |
| 1 | Repeated squaring |
Total | 3 |
The course taxonomy places pp under Array Basics. Here, its main solving operation gives it the loops and binary representation label. An array stores the bits, but tracking those bits through repeated squaring explains the answer. Topic overlap does not create an extra question.
Arrays and pointers: why the expression prints 19
![Array-pointer trace highlights row 3, column 3, where a[3][3] equals 19.](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1793312524899_frbo5d.jpg)
Find the output of this array expression:
int a[4][5] = {{1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
{16,17,18,19,20}};
printf("%d\n", *(*(a+**a+2)+3));(GATE 2020, array-pointer solved trace)
Start at the innermost value, then track the pointer's unit:
**a = a[0][0] = 1.a + **a + 2 = a + 1 + 2 = a + 3, selecting row index 3.*(a + 3)gives the fourth row, which decays to a pointer to its first integer in this addition.*(a + 3) + 3points to column index 3. The final dereference readsa[3][3] = 19.
The output is 19. In a+1, one step crosses a row of five integers. After selecting the row, +3 crosses three integers. No assumed byte width is needed. The trap is treating both additions as single-integer moves; review the pointer arithmetic rules if that distinction is unclear.
![A 4-by-5 integer grid highlights a[0][0]=1, row 3, column 3, and the selected value a[3][3]=19.](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1790057350927_qlhz9u.jpg)
Recursion and static variables: tracing fun2(5) to 55
Find fun2(5) in a fresh execution:
int fun1(int n) {
static int i = 0;
if (n > 0) {
++i;
fun1(n-1);
}
return(i);
}
int fun2(int n) {
static int i = 0;
if (n > 0) {
i = i + fun1(n);
fun2(n-1);
}
return(i);
}(GATE 2020, static-variable recursion solution)
There are two distinct static objects, initially zero. Each persists across calls to its own function. fun1(n) increments its static n times; it does not restart at zero when called again.
|
|
|
|---|---|---|
5 | 0+5 = 5 | 0+5 = 5 |
4 | 5+4 = 9 | 5+9 = 14 |
3 | 9+3 = 12 | 14+12 = 26 |
2 | 12+2 = 14 | 26+14 = 40 |
1 | 14+1 = 15 | 40+15 = 55 |
At n=0, fun2 returns 55. Every unwinding frame also reads the same static and returns 55, even though the recursive return value is ignored. The two variables share a name, not storage. Since fun1 never changes fun2's i, operand evaluation order in i + fun1(n) does not change this result.
Binary representation and loops: why pp(3,4) returns 81
Find the value returned by pp(3,4):
int tob(int b, int* arr) {
int i;
for (i=0; b>0; i++) {
if (b%2) arr[i]=1;
else arr[i]=0;
b=b/2;
}
return(i);
}
int pp(int a, int b) {
int arr[20];
int i, tot=1, ex, len;
ex=a;
len=tob(b,arr);
for (i=0; i<len; i++) {
if (arr[i]==1)
tot=tot*ex;
ex=ex*ex;
}
return(tot);
}(GATE 2020, repeated-squaring solved trace)
Integer division takes b through 4 to 2 to 1 to 0. The remainders are 0,0,1, so arr stores the bits least significant first, and len=3. This reverses the usual written order of binary 100.
| Bit |
|
|
|
|---|---|---|---|---|
0 | 0 | 3 | 1 | 3x3 = 9 |
1 | 0 | 9 | 1 | 9x9 = 81 |
2 | 1 | 81 | 1x81 = 81 | 81x81 = 6561 |
Only the last stored bit triggers multiplication into tot. The final squaring still executes, but the returned total remains 81, matching 3^4. Trace the two functions together instead of guessing from their names.
Difficulty comes from state tracking, not code length
The main risk is state tracking: the array expression is short once row types are recognised, static recursion carries greater bookkeeping risk, and pp requires connecting two functions while preserving bit order.
These traces use different state models: pointer arithmetic changes the object selected, static storage preserves state across calls, and the binary loop stores exponent bits least-significant first. A correct trace records the state after each operation, then checks the final value against the return path.
Close the tables and reproduce 19, 55 and 81. For each miss, record the cause: wrong pointer unit, reset static state, or reversed bit order. Repair that specific step before attempting another question. Recalling the final answer without a valid trace is not mastery.
If your errors span several concepts, the six-week C revision plan helps organise the next round of practice.
Turn the three traces into your next practice session
Use a two-pass 25-minute drill: spend 5 minutes writing a state column for each trace, 15 minutes re-deriving 19, 55 and 81 without notes, and 5 minutes classifying the first wrong transition. The next day, rebuild all three traces on blank paper and explain each state change aloud.
Prioritise the concept behind your first incorrect step. If you need to rebuild those foundations before more PYQs, use the C Language course for concept repair.
Keep learning
GATE 2017 C Programming Questions: Topic Breakdown and Worked Traces
Trace the values that decide the answer: copied pointer values, persistent static counts and recursive calls that never progress. This selected 2017 question set turns those mistakes into a focused revision session.
GATE 2016 C Programming Questions: Topic Map and Worked Traces
Trace caller state, shared static storage and array recurrences in selected GATE 2016 questions. Use the worked answers to identify what to practise next.
GATE 2019 C Programming Questions: Topic Map and Six Worked Traces
Remembering an output is easier than explaining it. Trace six GATE 2019 C Programming questions, identify the exact execution traps, and use your mistakes to plan revision.
GATE 2014 C Programming Questions: Topic Analysis and Worked Traces
Trace seven selected GATE 2014 C questions to understand pointer input, double swaps, search boundaries and integer arithmetic. Use the mistakes to guide a focused revision session.





