Free tutorials in Hindi & English Daily computer, mobile and IT guides Beginner friendly learning
Blog · C Pointers · 03 Jul 2026 · Hindi + English

Top 15 Pointer Interview Questions in C with Answers

15 most-asked pointer interview questions: NULL vs void vs wild vs dangling, pointer arithmetic outputs, arrays vs pointers and double pointers.

How to use this list

These 15 questions cover the pointer topics asked in nearly every C interview and viva — definitions, the 4 special pointer types, arithmetic outputs and array/string traps. Attempt each answer before reading it.

Basics (1–5)

Q1. What is a pointer?

A variable that stores the memory address of another variable, enabling indirect access via the * (dereference) operator.

Q2. What is the size of a pointer?

It depends on the architecture, not the pointed type: 8 bytes on 64-bit, 4 bytes on 32-bit. int*, char* and double* all have the same size on one machine.

Q3. Differentiate NULL, wild and dangling pointers.

NULL: intentionally points to nothing (address 0), safe to test. Wild: uninitialized, holds garbage. Dangling: held a valid address, but the memory was freed or destroyed.

Q4. What is a void pointer?

A generic pointer (void *) that can hold any type's address but must be typecast before dereferencing. malloc returns void*.

Q5. What is pointer to pointer?

A pointer storing another pointer's address (int **pp). Needed when a function must change where the caller's pointer points, e.g. linked list insert(struct Node **head).

Arithmetic and arrays (6–10)

Q6. If int *p holds address 1000, what is p+3?

1012 (assuming 4-byte int): pointer arithmetic moves in units of sizeof(type), so 1000 + 3×4.

Q7. Are arr[i] and *(arr+i) the same?

Yes — the compiler defines arr[i] as *(arr+i). Fun consequence: i[arr] also compiles and works.

Q8. What does subtracting two pointers give?

The number of elements between them (not bytes), valid only within the same array.

Q9. Is an array name a pointer?

No. It decays to a pointer in most expressions, but sizeof(arr) gives the whole array size and arr cannot be reassigned or incremented.

Q10. Predict: char *p = "hello"; p[0]='H';

Undefined behaviour, usually a crash — string literals live in read-only memory. char arr[]="hello"; arr[0]='H'; is fine (writable copy).

Advanced (11–15)

Q11. Difference between const int *p and int *const p?

const int *p: value locked, pointer movable. int *const p: pointer locked, value modifiable. Read declarations right to left.

Q12. What is a function pointer and one real use?

A pointer holding a function's address: int (*fp)(int,int). Real use: the comparison callback passed to qsort().

Q13. Why does swap(int a, int b) fail and swap(int *a, int *b) work?

C is call-by-value: the first swaps copies. Passing addresses lets the function modify the caller's originals through dereference — this is "call by reference" simulated with pointers.

Q14. What is a memory leak?

malloc'd memory whose last pointer is lost before free() — the block stays allocated but unreachable. Repeated leaks exhaust memory in long-running programs.

Q15. Predict the output:

int arr[] = {10, 20, 30};
int *p = arr;
printf("%d %d %d", *p++, *p, ++*p);

Answer: unspecified/undefined — the evaluation order of printf arguments is not defined in C, and modifying p and *p between sequence points makes results compiler-dependent. The correct interview answer is to identify the undefined behaviour, not to guess numbers.

इस list को कैसे use करें

ये 15 questions लगभग हर C interview और viva में पूछे जाने वाले pointer topics cover करते हैं — definitions, 4 special pointer types, arithmetic outputs और array/string traps. हर answer पढ़ने से पहले खुद try करें.

Basics (1–5)

Q1. Pointer क्या है?

वह variable जो दूसरे variable का memory address store करता है, और * (dereference) operator से indirect access देता है.

Q2. Pointer का size क्या होता है?

Architecture पर depend करता है, pointed type पर नहीं: 64-bit पर 8 bytes, 32-bit पर 4 bytes. एक machine पर int*, char* और double* सबका size same.

Q3. NULL, wild और dangling pointers में अंतर बताएं.

NULL: जानबूझकर कहीं point नहीं करता (address 0), test करने में safe. Wild: uninitialized, garbage रखता है. Dangling: valid address था, लेकिन memory free या destroy हो गई.

Q4. Void pointer क्या है?

Generic pointer (void *) जो किसी भी type का address रख सकता है लेकिन dereference से पहले typecast ज़रूरी. malloc void* return करता है.

Q5. Pointer to pointer क्या है?

दूसरे pointer का address रखने वाला pointer (int **pp). तब चाहिए जब function को caller का pointer कहां point करे यह बदलना हो, जैसे linked list insert(struct Node **head).

Arithmetic और arrays (6–10)

Q6. अगर int *p में address 1000 है, तो p+3 क्या है?

1012 (4-byte int मानकर): pointer arithmetic sizeof(type) units में चलता है, इसलिए 1000 + 3×4.

Q7. क्या arr[i] और *(arr+i) same हैं?

हां — compiler arr[i] को *(arr+i) define करता है. मज़ेदार consequence: i[arr] भी compile होकर काम करता है.

Q8. दो pointers घटाने पर क्या मिलता है?

दोनों के बीच elements की संख्या (bytes नहीं), सिर्फ same array में valid.

Q9. क्या array name pointer है?

नहीं. ज़्यादातर expressions में pointer में decay होता है, लेकिन sizeof(arr) पूरे array का size देता है और arr को reassign/increment नहीं कर सकते.

Q10. Predict करें: char *p = "hello"; p[0]='H';

Undefined behaviour, आमतौर पर crash — string literals read-only memory में रहते हैं. char arr[]="hello"; arr[0]='H'; ठीक है (writable copy).

Advanced (11–15)

Q11. const int *p और int *const p में अंतर?

const int *p: value locked, pointer movable. int *const p: pointer locked, value modifiable. Declarations right से left पढ़ें.

Q12. Function pointer क्या है और एक real use?

Function का address रखने वाला pointer: int (*fp)(int,int). Real use: qsort() को pass किया जाने वाला comparison callback.

Q13. swap(int a, int b) fail और swap(int *a, int *b) क्यों काम करता है?

C call-by-value है: पहला copies swap करता है. Addresses pass करने पर function dereference से caller के originals modify कर सकता है — यही pointers से simulated "call by reference" है.

Q14. Memory leak क्या है?

ऐसी malloc हुई memory जिसका आखिरी pointer free() से पहले खो गया — block allocated रहता है लेकिन unreachable. लंबे चलने वाले programs में बार-बार leaks memory खत्म कर देते हैं.

Q15. Output predict करें:

int arr[] = {10, 20, 30};
int *p = arr;
printf("%d %d %d", *p++, *p, ++*p);

Answer: unspecified/undefined — C में printf arguments का evaluation order defined नहीं है, और sequence points के बीच p व *p को modify करने से result compiler-dependent हो जाता है. सही interview answer undefined behaviour को identify करना है, numbers guess करना नहीं.

Frequently Asked Questions

What is the most asked pointer interview question?

Explaining the difference between NULL, wild and dangling pointers, followed closely by the const int *p vs int *const p distinction.

Why does swapping with plain int parameters fail?

C passes arguments by value, so the function swaps local copies; passing pointers lets it modify the caller's originals through dereferencing.

What is a memory leak in C?

Allocated heap memory that becomes unreachable because every pointer to it was lost or overwritten before calling free().