All Articles
Coding Concepts10 min read•Sep 10, 2026

10 Tricky C Programming Pointers & Recursion Traps Frequently Asked in WB JECA

Step-by-step memory dry-run tables for pointer arithmetic, pre/post increment, string literals, and recursive stack activations.

JM

JECA Master Academic Team

Lead Systems & C Engineering Faculty

Why C Programming is the Deciding Factor in WB JECA

In WB JECA, C Programming questions are intentionally constructed with subtle compiler nuances, pointer arithmetic, and operator precedence traps that cannot be solved through rote memorization.

Here are 5 of the most repeated traps from previous WB JECA question papers, with complete dry-run memory traces.


Trap 1: sizeof() Operator on Array vs Pointer Parameter

Consider the following C snippet:

#include <stdio.h>

void func(int arr[]) {
    printf("%zu ", sizeof(arr));
}

int main() {
    int arr[10];
    printf("%zu ", sizeof(arr));
    func(arr);
    return 0;
}

Question: What is the output on a 64-bit architecture?

  • A) 40 40

  • B) 40 8 (Correct)

  • C) 10 10

  • D) 8 8

Analysis & Dry Run:

  1. In main(), arr is a true stack-allocated array of 10 integers. Since sizeof(int) = 4, sizeof(arr) = 10 * 4 = 40 bytes.

  2. When arr is passed to func(int arr[]), it decays into a pointer to its first element: int *arr.

  3. On a modern 64-bit architecture, any pointer variable occupies 8 bytes.

  4. Therefore, func() prints 8. Output: 40 8.


Trap 2: Modification of String Literals vs Character Arrays

char *p = "JECA";
char s[] = "JECA";

s[0] = 'M'; // Valid! Modifies stack memory
p[0] = 'M'; // SEGMENTATION FAULT at runtime!
  • char *p = "JECA"; stores the string literal in the read-only text/data segment (rodata) of memory. Attempting to write to it triggers a memory protection fault.

  • char s[] = "JECA"; copies the characters into stack memory, where write operations are fully permitted.


Trap 3: Pointer Arithmetic and Scaling

If integer pointer ptr points to address 0x1000, what is ptr + 3?

$$\text{Address} = \text{Base} + (3 \times \text{sizeof}(*\text{ptr})) = 0x1000 + (3 \times 4) = 0x1000 + 12 = 0x100C$$

Always remember: Pointer arithmetic scales automatically by the sizeof(data_type)!


Trap 4: Recursive Function Return Evaluation

What is the return value of mystery(5)?

int mystery(int n) {
    if (n <= 1) return 1;
    return n + mystery(n - 2);
}

Stack Trace:

  • mystery(5) = 5 + mystery(3)

  • mystery(3) = 3 + mystery(1)

  • mystery(1) = 1 (Base case)

  • Evaluation: $5 + (3 + 1) = 9$.


Key Takeaway for Exam Day

Whenever you see pointer and array combinations like *(*arr + 1) or *ptr++, immediately write down the memory addresses and variable pointers on your scrap paper. Dry-running beats guessing every time!

Related Tags:#C Programming#Pointers#Recursion#Memory Traps#WBJEEB
Targeting Top Rank?

Put Strategy Into Practice Right Now

Attempt a full-length diagnostic mock test for free with official negative marking and state rank prediction.

Start Free Mock Test →