Pointers— Concepts, Formulas & Shortcuts
- A pointer stores the address of a variable: int *p = &x; dereference with *p.
- Pointer arithmetic scales by sizeof(type): for int* on a 32-bit int, p + 1 advances 4 bytes.
- An array name decays to a pointer to its first element, so arr[i] is identical to *(arr + i).
- sizeof(array) gives the whole array size, but sizeof(pointer) gives only the pointer size — this is why array size is lost inside a function.
- A NULL pointer points to nothing; dereferencing it is undefined behaviour, usually a segmentation fault.
- C passes arguments by value, so swapping two variables inside a function requires passing their addresses.
Pointers Practice Questions with Answers
Attempt each question first, then open the explanation. All 8 questions below are free to read and require no signup.
Q1.What does the following print? int x = 5; int *p = &x; printf("%d", *p);
Easy- A5
- BAddress of x
- CGarbage value
- DCompilation error
Pointers question 1 of 8+Show Answer & Explanation
Answer: A. 5
Explanation: *p dereferences the pointer, giving the value stored at the address of x, which is 5.
Q2.If p is an int pointer holding address 1000 and int is 4 bytes, what is the value of p + 2?
Moderate- A1002
- B1004
- C1008
- D2000
Pointers question 2 of 8+Show Answer & Explanation
Answer: C. 1008
Explanation: Pointer arithmetic scales by sizeof(int): 1000 + 2 × 4 = 1008.
Q3.Which expression is equivalent to arr[3] for an array arr?
Moderate- A*(arr + 3)
- B*arr + 3
- C&arr + 3
- Darr + 3
Pointers question 3 of 8+Show Answer & Explanation
Answer: A. *(arr + 3)
Explanation: Subscripting is defined as arr[i] ≡ *(arr + i). The other options either add to the value or produce an address.
Q4.What is a NULL pointer in C?
Easy- AA pointer holding garbage
- BA pointer that does not point to any valid location
- CAn uninitialised pointer
- DA pointer to zero-sized memory
Pointers question 4 of 8+Show Answer & Explanation
Answer: B. A pointer that does not point to any valid location
Explanation: A NULL pointer is guaranteed not to point to any object. It differs from an uninitialised pointer, which holds an unpredictable address.
Q5.To swap two integers inside a function, the parameters must be:
Moderate- APassed by value
- BPointers to the integers
- CDeclared const
- DDeclared static
Pointers question 5 of 8+Show Answer & Explanation
Answer: B. Pointers to the integers
Explanation: C passes by value, so the function must receive addresses and modify the originals through dereferencing.
Q6.What is the size of a pointer variable on a 64-bit system?
Easy- A2 bytes
- B4 bytes
- C8 bytes
- DDepends on the pointed-to type
Pointers question 6 of 8+Show Answer & Explanation
Answer: C. 8 bytes
Explanation: On a 64-bit platform all pointers are 8 bytes, regardless of the type they point to.
Q7.What does a double pointer (int **p) store?
Moderate- ATwo values
- BThe address of another pointer
- CA pointer to an array
- DTwice the memory
Pointers question 7 of 8+Show Answer & Explanation
Answer: B. The address of another pointer
Explanation: A double pointer holds the address of a pointer variable — commonly used for 2-D dynamic arrays and for modifying a pointer inside a function.
Q8.Accessing memory through a pointer after calling free() on it causes:
Difficult- AA compilation error
- BA guaranteed crash
- CUndefined behaviour (dangling pointer)
- DAutomatic reallocation
Pointers question 8 of 8+Show Answer & Explanation
Answer: C. Undefined behaviour (dangling pointer)
Explanation: The pointer becomes dangling. The behaviour is undefined — it may crash, may silently corrupt data, or may appear to work.
Pointers — Frequently Asked Questions
What is the difference between an array and a pointer in C?+
An array is a block of contiguous memory whose name decays to a pointer in most expressions; a pointer is a variable holding an address. sizeof reveals the difference — sizeof(arr) is the whole array, sizeof(ptr) is just the address size.
What is a dangling pointer?+
A pointer that still holds the address of memory that has been freed or has gone out of scope. Dereferencing it is undefined behaviour; set the pointer to NULL after free() to avoid it.
Cleared the aptitude round? Now grab the role.
Preparation only pays off when you apply. Thousands of internships and fresher jobs across India are live on MyInternships.in right now — free to apply, no consultancy fees.
