Pointer Practice questions in C and C++ with clear explanations, memory concepts, and real coding examples. Perfect for beginners and interview prep.
Pointer Practice Questions are designed to help beginners and intermediate programmers master pointers step by step. This collection includes easy to advanced pointer questions with clear explanations, real coding logic, and common interview-based problems to improve your confidence in C and C++ programming.
Pointer Basic Question
1. What is the output?
#include
int main() {
int a = 10;
int *p = &a;
printf("%d", *p);
return 0;
}
Answer:10
Why:p stores address of a.*p gives the value stored at that address → 10.
2. What will be printed?
int a = 5;
int *p = &a;
printf("%d", a);
Answer:5
Why:
Pointer is not used in printf. Direct variable access.
3. What is the output?
int a = 7;
int *p;
p = &a;
printf("%d", *p);
Answer:7
Why:
Pointer assigned later, still valid.
4. Identify correct pointer declaration
int a = 10;
int *p = a;
Answer:
Compilation Error
Why:
Pointer must store address, not value.
Correct:
int *p = &a;
5. What will be the output?
int a = 10;
int *p = &a;
*p = 20;
printf("%d", a);
Answer:20
Why:
Changing *p changes the value of a.
6. What is printed?
int a = 3;
int b = 4;
int *p = &a;
p = &b;
printf("%d", *p);
Answer:4
Why:
Pointer now points to b.
7. What is the output?
int a = 5;
int *p = &a;
printf("%p", p);
Answer:
Address of a (hex value)
Why:%p prints memory address.
8. What will be printed?
int a = 10;
int *p = &a;
printf("%p", &a);
Answer:
Same address as pointer value.
Why:p == &a
Output?
int a = 1;
int b = 2;
int *p = &a;
*p = b;
printf("%d", a);
Answer:2
Why:*p = b assigns value of b to a.
10. What happens?
int *p;
printf("%d", *p);
Answer:
Undefined Behavior
Why:
Pointer is uninitialized.
11. Output?
int a = 10;
int *p = &a;
printf("%d %d", a, *p);
Answer:10 10
12. Pointer and variable relation
int a = 5;
int *p = &a;
a = 8;
printf("%d", *p);
Answer:8
Why:
Pointer always reflects current value of variable.
13. Output?
int a = 10;
int *p = &a;
printf("%d", ++(*p));
Answer:11
Why:
Increment value at address.
14. What will be printed?
int a = 10;
int *p = &a;
(*p)++;
printf("%d", a);
Answer:11
15. Output?
int a = 10;
int *p = &a;
printf("%d", *p++);
Answer:
Tricky / Undefined for beginner
Why:
Pointer moves, dereference happens first.
Avoid this at beginner level.
Correct way to print value using pointer?
Correct answer:
printf("%d", *p);
Wrong:
printf("%d", p);
16. Output?
int a = 5;
int *p = &a;
*p = *p + 5;
printf("%d", a);
Answer:10
17. What will be printed?
int a = 10;
int b = 20;
int *p = &a;
int *q = &b;
printf("%d %d", *p, *q);
Answer:10 20
18. Output?
int a = 100;
int *p = &a;
printf("%d", *(&a));
Answer:100
Why:&a gives address, * gets value.
19. Final beginner check
int a = 10;
int *p = NULL;
p = &a;
printf("%d", *p);
Answer:10
Why:
Pointer safely assigned before use.

POINTER + ARRAY
1. What is the output?
int arr[] = {10, 20, 30, 40};
int *p = arr;
printf("%d", *p);
Answer:10
Why:
Array name stores address of first element.
2. Output?
int arr[] = {5, 10, 15};
int *p = arr;
printf("%d", *(p + 1));
Answer:10
Why:p + 1 → next integer (4 bytes ahead).
Output?
int arr[] = {1, 2, 3};
int *p = arr;
printf("%d", *(arr + 2));
Answer:3
Why:arr behaves like pointer to first element.
3.What will be printed?
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d", p[1]);
Answer:20
Why:p[i] is same as *(p + i).
4.Output?
int arr[] = {10, 20, 30};
printf("%d", *(arr + 1));
Answer:20
5. Output?
int arr[] = {10, 20, 30};
printf("%d", arr[2]);
Answer:30
6. Output?
int arr[] = {1, 2, 3};
int *p = arr;
printf("%d", *p + 1);
Answer:2
Why:
Dereference first → 1 + 1.
7. Output?
int arr[] = {1, 2, 3};
int *p = arr;
printf("%d", *(p + 1) + 1);
Answer:3
8. Output?
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d", *p++);
Answer:10
Why:
Dereference first, then pointer moves.
POINTER ARITHMETIC
1.Output?
int arr[] = {10, 20, 30};
int *p = arr;
p++;
printf("%d", *p);
Answer:20
Why:
Pointer moves to next element.
2. Output?
int arr[] = {10, 20, 30};
int *p = &arr[1];
printf("%d", *(p - 1));
Answer:10
3. Output?
int arr[] = {5, 10, 15};
int *p = arr;
printf("%d", *(p + 2));
Answer:15
4. What will be printed?
int arr[] = {1, 2, 3, 4};
int *p = arr;
printf("%d", *(p + 3));
Answer:4
5. Output?
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d", *(++p));
Answer:20
Why:
Pointer increment happens first.
6. Output?
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d", *(p++));
Answer:10
7. Output?
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d %d", *p, *(p + 1));
Answer:10 20
8. Output?
int arr[] = {10, 20, 30};
int *p = arr;
*p = *(p + 2);
printf("%d", arr[0]);
Answer:30
9. Output?
int arr[] = {1, 2, 3};
int *p = arr;
*(p + 1) = 10;
printf("%d", arr[1]);
Answer:10
10. Output?
int arr[] = {2, 4, 6};
int *p = arr;
printf("%d", *(p + 1) * 2);
Answer:8
11. Array traversal using pointer
int arr[] = {1, 2, 3};
int *p = arr;
for(int i = 0; i < 3; i++) {
printf("%d ", *(p + i));
}
Answer:1 2 3
POINTER + FUNCTION PRACTICE QUESTIONS

1. Passing variable by value
#include
void update(int x) {
x = 20;
}
int main() {
int a = 10;
update(a);
printf("%d", a);
}
Answer:10
Why:
Only copy of a is passed.
2. Passing variable using pointer
void update(int *x) {
*x = 20;
}
int main() {
int a = 10;
update(&a);
printf("%d", a);
}
Answer:20
Why:
Pointer modifies original variable.
3. Output?
void change(int *p) {
*p = *p + 5;
}
int main() {
int a = 10;
change(&a);
printf("%d", a);
}
Answer:15
4. Swap without pointer
void swap(int a, int b) {
int t = a;
a = b;
b = t;
}
int main() {
int x = 10, y = 20;
swap(x, y);
printf("%d %d", x, y);
}
Answer:10 20
Why:
Swap fails without pointers.
5. Swap using pointer
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
int main() {
int x = 10, y = 20;
swap(&x, &y);
printf("%d %d", x, y);
}
Answer:20 10
6. Passing array to function
void print(int *p) {
printf("%d", p[1]);
}
int main() {
int arr[] = {10, 20, 30};
print(arr);
}
Answer:20
Why:
Array decays to pointer.
7. Same example, different syntax
void print(int p[]) {
printf("%d", *(p + 2));
}
int main() {
int arr[] = {5, 10, 15};
print(arr);
}
Answer:15
8. Modify array inside function
void update(int *p) {
p[0] = 100;
}
int main() {
int arr[] = {1, 2, 3};
update(arr);
printf("%d", arr[0]);
}
Answer:100
9. Output?
void test(int *p) {
p++;
printf("%d ", *p);
}
int main() {
int arr[] = {10, 20, 30};
test(arr);
}
Answer:20
10. Output?
void test(int *p) {
*p = *(p + 1);
}
int main() {
int arr[] = {5, 10, 15};
test(arr);
printf("%d", arr[0]);
}
Answer:10
11. Pointer returned from function
int* getValue() {
static int a = 10;
return &a;
}
int main() {
int *p = getValue();
printf("%d", *p);
}
Answer:10
Why:
Static variable survives function end.
12. Wrong pointer return
int* getValue() {
int a = 10;
return &a;
}
Answer:
Undefined behavior
Why:
Local variable destroyed.
13. Output?
void fun(int *p) {
*p += 10;
}
int main() {
int a = 5;
fun(&a);
printf("%d", a);
}
Answer:15
14. Function with pointer arithmetic
void print(int *p) {
printf("%d", *(p + 1));
}
int main() {
int arr[] = {3, 6, 9};
print(arr);
}
Answer:6
15. Call by reference concept
void change(int *x) {
*x = 50;
}
int main() {
int a = 10;
change(&a);
printf("%d", a);
}
Answer:50
16. Passing pointer itself
void update(int **p) {
**p = 30;
}
int main() {
int a = 10;
int *p = &a;
update(&p);
printf("%d", a);
}
Answer:30
Why:
Double pointer used.
17. Output?
void fun(int *p) {
p = p + 1;
}
int main() {
int arr[] = {10, 20, 30};
fun(arr);
printf("%d", arr[1]);
}
Answer:20
Why:
Pointer copy changes only inside function.
18. Modify array using function
void fun(int p[]) {
p[2] = 99;
}
int main() {
int arr[] = {1, 2, 3};
fun(arr);
printf("%d", arr[2]);
}
Answer:99
19. Output?
void fun(int *p) {
*(p + 1) = *(p) + 5;
}
int main() {
int arr[] = {10, 20, 30};
fun(arr);
printf("%d", arr[1]);
}
Answer:15
20. Interview golden rule check
void fun(int *p) {
p = NULL;
}
int main() {
int a = 10;
int *p = &a;
fun(p);
printf("%d", *p);
}
Answer:10
Why:
Pointer passed by value.
DOUBLE POINTER (**) PRACTICE QUESTIONS
1. What is a Double Pointer?
int a = 10;
int *p = &a;
int **pp = &p;
| Variable | Stores |
|---|---|
a | Value |
p | Address of a |
pp | Address of p |
2. Basic output
int a = 10;
int *p = &a;
int **pp = &p;
printf("%d", **pp);
Answer:10
Why:pp → p → a
3. Output?
int a = 20;
int *p = &a;
int **pp = &p;
printf("%d %d", *p, **pp);
Answer:20 20
4. Modify value using double pointer
int a = 5;
int *p = &a;
int **pp = &p;
**pp = 15;
printf("%d", a);
Answer:15
5. Modify pointer using double pointer
void update(int **pp) {
**pp = 100;
}
int main() {
int a = 10;
int *p = &a;
update(&p);
printf("%d", a);
}
Answer:100
6. Change pointer address
void fun(int **pp, int *q) {
*pp = q;
}
int main() {
int a = 10, b = 20;
int *p = &a;
fun(&p, &b);
printf("%d", *p);
}
Answer:20
Why:
Pointer p now points to b.
7. Output?
int a = 5;
int *p = &a;
int **pp = &p;
printf("%d", *(*pp));
Answer:5
8. Pass pointer to function
void fun(int **pp) {
**pp += 10;
}
int main() {
int a = 10;
int *p = &a;
fun(&p);
printf("%d", a);
}
Answer:20
9. Output?
void fun(int **pp) {
*pp = *pp + 1;
}
int main() {
int arr[] = {10, 20, 30};
int *p = arr;
fun(&p);
printf("%d", *p);
}
Answer:20
Why:
Pointer moved to next element.
10. Array access via double pointer
int arr[] = {1, 2, 3};
int *p = arr;
int **pp = &p;
printf("%d", *(*pp + 2));
Answer:3
11. Pointer levels
int a = 10;
int *p = &a;
int **pp = &p;
printf("%p %p", (void*)p, (void*)*pp);
Answer:
Both addresses are same.
12. Wrong usage
int **pp;
printf("%d", **pp);
Answer:
Undefined behavior
Why:
Double pointer not initialized.
13. Output?
int a = 10;
int *p = &a;
int **pp = &p;
*p = 20;
printf("%d", **pp);
Answer:20
14. Return pointer using double pointer
void getPtr(int **pp) {
static int x = 50;
*pp = &x;
}
int main() {
int *p;
getPtr(&p);
printf("%d", *p);
}
Answer:50
15. Modify array using double pointer
void update(int **pp) {
**pp = 99;
}
int main() {
int arr[] = {1, 2, 3};
int *p = arr;
update(&p);
printf("%d", arr[0]);
}
Answer:99
16.Output?
void fun(int **pp) {
*pp = NULL;
}
int main() {
int a = 10;
int *p = &a;
fun(&p);
// printf("%d", *p); // unsafe
}
Answer:
Pointer becomes NULL
Why:
Double pointer modifies pointer itself.
16. Real interview trap
void fun(int **pp) {
int x = 10;
*pp = &x;
}
Answer:
Dangerous
Why:
Returning address of local variable.
17. Double pointer + function logic
void swap(int **p, int **q) {
int *t = *p;
*p = *q;
*q = t;
}
int main() {
int a = 10, b = 20;
int *p = &a;
int *q = &b;
swap(&p, &q);
printf("%d %d", *p, *q);
}
Answer:20 10
18. Output?
int a = 5;
int *p = &a;
int **pp = &p;
printf("%d", **pp + 5);
Answer:10
19. Pointer chain understanding
int a = 1;
int *p = &a;
int **pp = &p;
**pp = **pp + 9;
printf("%d", a);
Answer:10
INTERVIEW GOLD QUESTION
When to use double pointer?
Answer:
- To modify pointer inside function
- Dynamic memory allocation
- Linked list operations
- Callback registration
- 2D arrays (advanced)
INTERVIEW GOLD RULES
*p→ value**pp→ value via pointer- Double pointer changes pointer
- Never leave pointer uninitialized
- Static or heap memory only
FAQ : POINTER PRACTICE QUESTIONS
1. What are pointer practice questions?
Pointer practice questions are coding problems that help you understand how pointers store memory addresses and work in C and C++ programs.
2. Why are pointers important in C and C++?
Pointers allow efficient memory management, dynamic allocation, and faster program execution, making them a core concept in C and C++.
3. Are pointer practice questions good for beginners?
Yes, beginner-friendly pointer questions help learners understand memory concepts step by step without confusion.
4. What topics are covered in pointer practice questions?
They cover pointer basics, pointer arithmetic, null pointers, double pointers, arrays with pointers, and function pointers.
5. How do pointer questions help in interview preparation?
Most C and C++ interviews include pointer-based problems to test memory understanding and problem-solving skills.
6. What is the best way to practice pointers?
Start with simple pointer programs, visualize memory, and then move to advanced practice questions.
7. Do pointer practice questions include real coding examples?
Yes, good pointer practice questions use real code examples to explain how memory and addresses work.
8. What are common mistakes students make with pointers?
Common mistakes include uninitialized pointers, incorrect memory access, and misunderstanding pointer arithmetic.
9. Are pointer practice questions useful for exams?
Absolutely. Pointer questions are frequently asked in university exams and competitive programming tests.
10. What is pointer arithmetic and why is it important?
Pointer arithmetic helps you navigate memory locations, especially when working with arrays and dynamic memory.
11. Can pointer practice questions improve coding logic?
Yes, they improve logical thinking, memory handling, and understanding of low-level program behavior.
12. Are pointers still relevant in modern programming?
Yes, pointers are widely used in system programming, embedded systems, and performance-critical applications.
13. How many pointer questions should I practice?
Practice at least 30–50 pointer questions to gain confidence and mastery over pointer concepts.
14. Do these questions help in competitive programming?
Yes, pointer practice improves memory optimization and code efficiency in competitive programming.
Read More : FPGA Interview Questions & Answers
Mr. Raj Kumar is a highly experienced Technical Content Engineer with 7 years of dedicated expertise in the intricate field of embedded systems. At Embedded Prep, Raj is at the forefront of creating and curating high-quality technical content designed to educate and empower aspiring and seasoned professionals in the embedded domain.
Throughout his career, Raj has honed a unique skill set that bridges the gap between deep technical understanding and effective communication. His work encompasses a wide range of educational materials, including in-depth tutorials, practical guides, course modules, and insightful articles focused on embedded hardware and software solutions. He possesses a strong grasp of embedded architectures, microcontrollers, real-time operating systems (RTOS), firmware development, and various communication protocols relevant to the embedded industry.
Raj is adept at collaborating closely with subject matter experts, engineers, and instructional designers to ensure the accuracy, completeness, and pedagogical effectiveness of the content. His meticulous attention to detail and commitment to clarity are instrumental in transforming complex embedded concepts into easily digestible and engaging learning experiences. At Embedded Prep, he plays a crucial role in building a robust knowledge base that helps learners master the complexities of embedded technologies.












