Test your understanding of C pointers with these 18 multiple-choice questions — dereferencing, pointer arithmetic, pointers and arrays, pointers to functions, and the classic traps. Every question has the answer and a short explanation hidden below it, and the trickier ones link to a full walkthrough with compilable code.
These questions come from our free Android app, C Programming Quiz — 150+ questions across 9 categories with score tracking, if you prefer to practise on your phone.
How to use this page: answer each question yourself before tapping Show answer. If you get one wrong, follow the linked explanation — knowing why the wrong options are wrong is what interviews test.
Question 1 of 18 (Easy)
What is the output of this code?
int a = 10;
int *p = &a;
printf("%d", *p);
- 10
- Address of a
- Garbage value
- Compile error
Show answer
Answer: A — 10
p stores the address of a; dereferencing it with *p reads the value stored there, which is 10.
Full walkthrough with compilable code: read the detailed explanation.
Question 2 of 18 (Medium)
Which statement about a null pointer is correct?
- It is guaranteed not to point to any object
- It points to the first byte of the program
- It points to a random address
- It always points to the top of the stack
Show answer
Answer: A — It is guaranteed not to point to any object
A null pointer compares unequal to a pointer to any object. Dereferencing it is undefined behavior. It is the canonical 'points to nothing valid' value.
Question 3 of 18 (Medium)
What is the output of this code?
int arr[] = {1, 2, 3};
int *p = arr;
printf("%d", *(p + 1));
- 1
- 2
- 3
- An address
Show answer
Answer: B — 2
p points to arr[0]. p + 1 points to arr[1] (pointer arithmetic scales by element size), so *(p + 1) is 2.
Full walkthrough with compilable code: read the detailed explanation.
Question 4 of 18 (Medium)
What does the declaration 'int **p;' mean?
- A pointer to a pointer to int
- A pointer to an int array
- Two integer pointers
- An invalid declaration
Show answer
Answer: A — A pointer to a pointer to int
Each * adds one level of indirection. 'int **p' is a pointer to a pointer to int.
Question 5 of 18 (Medium)
What is the output of this code?
char *s = "abc";
printf("%c", *(s + 2));
- a
- b
- c
- abc
Show answer
Answer: C — c
s points to the start of the string. s + 2 points to the third character, so *(s + 2) is 'c'.
Full walkthrough with compilable code: read the detailed explanation.
Question 6 of 18 (Hard)
What is the output of this code?
int a = 5, b = 10;
int *p = &a, *q = &b;
*p = *q;
printf("%d %d", a, b);
- 5 10
- 10 10
- 10 5
- 5 5
Show answer
Answer: B — 10 10
*p = *q copies the value at q (10) into the location p points to (a). So a becomes 10; b is unchanged.
Full walkthrough with compilable code: read the detailed explanation.
Question 7 of 18 (Hard)
What is the output of this code?
int arr[] = {10, 20, 30};
int *p = arr + 2;
printf("%d", p[-1]);
- 10
- 20
- 30
- Undefined behavior
Show answer
Answer: B — 20
p points to arr[2]. Negative index p[-1] is valid here because it stays within the array bounds — it accesses arr[1] which is 20.
Full walkthrough with compilable code: read the detailed explanation.
Question 8 of 18 (Medium)
What does a function pointer declaration 'int (*fp)(int, int);' mean?
- fp is a pointer to a function taking two ints and returning int
- fp is a function returning a pointer to int
- fp is an array of function pointers
- fp is an invalid declaration
Show answer
Answer: A — fp is a pointer to a function taking two ints and returning int
The parentheses around *fp make fp a pointer. The full type is: pointer to function(int, int) returning int.
Question 9 of 18 (Easy)
What operator gives the address of a variable?
- *
- &
- ->
- @
Show answer
Answer: B — &
The address-of operator & gives the memory address where a variable is stored.
Question 10 of 18 (Hard)
What is the output of this code?
int x = 42;
void *vp = &x;
printf("%d", *(int *)vp);
- 42
- Address of x
- Compile error
- Undefined behavior
Show answer
Answer: A — 42
void* is a generic pointer. Casting it back to int* and dereferencing retrieves the original value 42. This is a valid pattern.
Full walkthrough with compilable code: read the detailed explanation.
Question 11 of 18 (Hard)
What is the output of this code?
int a[3] = {1, 2, 3};
printf("%d", 2[a]);
- 1
- 2
- 3
- Compile error
Show answer
Answer: C — 3
a[2] and 2[a] are identical — both expand to *(a + 2) = *(2 + a). This is a valid, if unusual, feature of C's array indexing.
Full walkthrough with compilable code: read the detailed explanation.
Question 12 of 18 (Medium)
What is the size of a pointer on a 64-bit system?
- 2 bytes
- 4 bytes
- 8 bytes
- Depends on the type pointed to
Show answer
Answer: C — 8 bytes
On a 64-bit platform, all pointers are 8 bytes regardless of what type they point to (int*, char*, void*, etc.).
Question 13 of 18 (Hard)
What is the output of this code?
int a = 1, b = 2;
void swap(int *x, int *y) {
int t = *x; *x = *y; *y = t;
}
swap(&a, &b);
printf("%d %d", a, b);
- 1 2
- 2 1
- Compile error
- Undefined behavior
Show answer
Answer: B — 2 1
Passing addresses lets swap modify the caller's variables. After the swap, a=2 and b=1.
Full walkthrough with compilable code: read the detailed explanation.
Question 14 of 18 (Medium)
What is the output of this code?
int a = 10;
int *p = &a;
(*p)++;
printf("%d", a);
- 10
- 11
- Compile error
- Undefined behavior
Show answer
Answer: B — 11
(*p)++ increments the value at the address p points to. Since p points to a, a becomes 11.
Full walkthrough with compilable code: read the detailed explanation.
Question 15 of 18 (Hard)
What is the output of this code?
char *arr[] = {"foo", "bar", "baz"};
printf("%s", arr[1]);
- foo
- bar
- baz
- Compile error
Show answer
Answer: B — bar
arr is an array of char pointers. arr[1] is the pointer to "bar". %s prints until the null terminator, giving "bar".
Full walkthrough with compilable code: read the detailed explanation.
Question 16 of 18 (Medium)
What is the output of this code?
int x = 5;
int *p = &x;
printf("%d", sizeof(p));
- 4
- 8
- 5
- Depends on the value of x
Show answer
Answer: B — 8
sizeof(p) gives the size of the pointer itself, not the value it points to. On a 64-bit system all pointers are 8 bytes.
Full walkthrough with compilable code: read the detailed explanation.
Question 17 of 18 (Hard)
Which is the correct way to declare a pointer to a const int?
- const int *p
- int const* p
- Both A and B are equivalent
- int *const p
Show answer
Answer: C — Both A and B are equivalent
'const int *p' and 'int const *p' are identical — both declare a pointer to a read-only int. 'int *const p' is a const pointer to (modifiable) int — different thing.
Question 18 of 18 (Easy)
What is the output of this code?
int x = 7;
int *p = &x;
printf("%d", *p + 1);
- 7
- 8
- Address of x + 1
- Compile error
Show answer
Answer: B — 8
*p dereferences p to get 7, then + 1 gives 8. The pointer itself is not moved.
Full walkthrough with compilable code: read the detailed explanation.
How Did You Score?
All 18 correct means this topic is interview-ready — try the harder timed rounds in the C Programming Quiz app. Missed a few? The guides below cover everything these questions test.
Keep Practising
- Pointers in C — A Complete Guide
- 25 C Pointer Interview Questions
- C Aptitude Questions and Answers
- All quiz question walkthroughs
More C Quizzes
- C Basics Quiz — 28 Questions with Answers
- C Operators Quiz — 20 Questions with Answers
- C Memory Management Quiz — 19 Questions with Answers
- C Arrays and Strings Quiz — 18 Questions with Answers
- C Functions Quiz — 15 Questions with Answers
- C Structs and Unions Quiz — 13 Questions with Answers
- C File I/O Quiz — 13 Questions with Answers
- C Preprocessor Quiz — 11 Questions with Answers