Don’t miss these must-know pointer questions for interviews. A simple, friendly guide covering basic to advanced pointers to help you prepare with confidence
Get interview-ready with this friendly and beginner-focused guide on the most important pointer questions. From simple pointer basics to advanced pointer tricks, everything is explained in an easy and clear way. Perfect for students, freshers, and professionals preparing for C, C++, or embedded interviews boost your confidence, strengthen your core concepts, and stay ahead in any technical round!
BEGINNER-LEVEL POINTER QUESTIONS
Basics
- What is a pointer in C/C++?
- Why do we use pointers?
- How do you declare a pointer?
- What is the size of a pointer?
- What does a NULL pointer mean?
- What is a wild pointer?
- What is a dangling pointer?
- What is pointer initialization?
- What is the difference between a pointer and a normal variable?
- What is the address-of operator (&)?
- What is the dereference operator (*)?
- How do you assign an address to a pointer?
- Can a pointer store NULL?
- What happens if you dereference an uninitialized pointer?
- What is a void pointer?
- What is the use of
void *? - What is the difference between
int *pandint* p? - What is
const int *p? - What is
int *const p? - What is
const int *const p?
INTERMEDIATE-LEVEL POINTER QUESTIONS
Pointer Arithmetic
- What is pointer arithmetic?
- Why does pointer arithmetic depend on data type size?
- Can we increment/decrement a void pointer?
- What happens when you compare two pointers?
- What is the difference between
p++and++*p? - How do you find the difference between two pointers?
- What is pointer scaling?
Function Pointers
- What is a function pointer?
- How do you declare a function pointer?
- Why do we use function pointers?
- What is a callback function?
- What is
typedeffor function pointers? - How do you pass a function pointer as a parameter?
- How do you return a function pointer from a function?
- What is a pointer to member function in C++?
Pointers & Arrays
- What is the relationship between pointers and arrays?
- Why does array name act like a pointer?
- Why can’t we assign to an array name?
- What is the difference between
arrand&arr? - What is the difference between
arrandarr[0]? - How do you use pointer arithmetic to traverse an array?
- What is a pointer to an array (
int (*p)[5])? - What is an array of pointers (
int* p[5])? - What is the difference between pointer to array and array of pointers?
- How do you pass a 2D array to a function using pointers?
Dynamic Memory
- What is dynamic memory allocation?
- What is
malloc,calloc,realloc,free? - What is memory leak?
- How do you avoid memory leaks?
- What is a double-free error?
- Why must you free allocated memory?
- What does
mallocreturn? - Why should you check if malloc returned NULL?
- What is segmentation fault in context of pointers?
ADVANCED-LEVEL POINTER QUESTIONS
Pointer to Pointer & Multi-Level Pointers
- What is a pointer to pointer (
int **p)? - Why do we use multiple levels of pointers?
- What is triple pointer (
int ***p) and where used? - How is pointer-to-pointer used in dynamic 2D arrays?
Constant Pointers & Qualifiers
- What is immutable pointer?
- What is mutable pointer?
- What is the importance of
constwith pointers in APIs?
Memory Alignment & Pointers
- What is memory alignment?
- What happens when a pointer is misaligned?
- What is strict aliasing rule?
- Why is pointer aliasing dangerous?
Function Pointer Tables
- What is a function pointer jump table?
- How are function pointer tables used in drivers?
- Why are function pointers used in State Machines?
- How do virtual function tables (vtable) use pointers?
Pointer Casting
- What is pointer typecasting?
- Is casting between unrelated pointers safe?
- What is
reinterpret_castin C++? - Why is
reinterpret_castdangerous? - What is
static_cast? - What is
dynamic_castand when to use?
Pointers in Embedded / System Programming
- What is memory-mapped I/O?
- How are pointers used for register access?
- Why do embedded systems use
volatilewith pointers? - What does
volatile uint32_t* reg = (uint32_t*)0x40002000;mean? - Why is volatile pointer different from pointer-to-volatile?
- Why do we use
uintptr_tfor pointer-to-integer conversions? - What happens if you access invalid memory in bare-metal?
Pointers & Data Structures
- How are pointers used in linked lists?
- How is a node created using pointers?
- Why do trees heavily use pointers?
- How do double pointers help in inserting nodes?
- How do pointers enable dynamic queues?
- Why are pointers critical in graph adjacency list?
Pointer Internals
- What is pointer indirection level?
- Why does pointer dereferencing take time?
- What are near, far, huge pointers (old compilers)?
- What is segmentation and offset in pointers?
- How do pointers work in 64-bit architecture?
- How do pointers behave in big-endian vs little-endian?
- Why can void* be assigned to any pointer?
- Why can’t you do arithmetic on void* in standard C?
Special Pointer Concepts
- What is a smart pointer?
- What is
unique_ptr,shared_ptr,weak_ptr? - How do smart pointers prevent memory leaks?
- What is custom deleter in smart pointers?
POINTER CODING EXERCISES
BEGINNER POINTER CODING EXERCISES
1. Print address and value using a pointer
Write a program to:
- Declare an int variable
- Store its address in a pointer
- Print the pointer value and pointed value
2. Swap two numbers using pointers
Use pointers to swap two integers without using a third variable.
3. Add two numbers using pointer variables
Pass pointer addresses to a function and return the sum.
4. Find length of a string using pointers
Implement strlen using only pointer arithmetic.
5. Copy string using pointers
Write custom strcpy using pointer-to-pointer increment.
6. Reverse a string using pointers
Use two pointers (start, end) to reverse a char array.
7. Print array elements using pointer arithmetic
Do not use indexing. Only *(p+i) or *p++.
8. Find maximum element in array using pointers
Pass array using pointer and find max using pointer arithmetic.
9. Count vowels in string using pointer traversal
Increment pointer to iterate over the string.
10. Check if the string is palindrome using pointers
Use two pointers: left and right.
INTERMEDIATE POINTER CODING EXERCISES
11. Dynamic array using malloc
- Ask user for size
- Allocate memory
- Fill and print elements
12. Implement your own strcat using pointers
Append second string to first using pointer increments.
13. Implement bubble sort using pointers
Sort using pointer arithmetic instead of indexing.
14. Create a function to return pointer to max element
Return pointer to largest element in an array.
15. Allocate memory for 2D array using double pointer
int **arr = malloc(rows * sizeof(int*)) … etc.
16. Write function to free dynamically allocated 2D array
Free inner + outer pointers properly.
17. Create a function pointer for arithmetic operations
Menu:
- add
- sub
- mul
- div
Select using function pointer array.
18. Use function pointers to implement a state machine
3 states: INIT → PROCESS → EXIT
Transitions via function pointer table.
19. Convert lowercase to uppercase using pointer traversal
Manipulate ASCII values via pointer.
20. Implement memory copy function (memcpy)
Use a pointer-to-pointer loop.
21. Implement strcmp using pointers
Return:
- 0 if equal
- -1 if first < second
- 1 if first > second
22. Pointer to array vs array of pointers
Write code demonstrating both with outputs.
23. Passing pointer-to-pointer to modify original pointer
Function should allocate memory and assign it back to caller.
24. Detect memory leak using pointers
Simulate:
- allocate
- forget to free
- show correction
ADVANCED POINTER CODING EXERCISES
25. Implement a dynamic linked list (insert/delete/traverse)
Use pointers heavily:
- malloc
- pointer-to-pointer for head
26. Implement a binary tree using struct pointers
Include:
- insert
- search
- inorder traversal
27. Create your own malloc() using static memory array
Simulate:
- Memory pool
- Allocation via pointers
28. Implement smart pointers in C++ (unique_ptr-like)
Show:
- RAII
- destructor deleting memory
29. Pointer alignment demonstration
Write code that prints pointer addresses and checks misalignment.
30. Implement callback mechanism using function pointers
User function gets executed through a callback argument.
31. Implement circular buffer using pointers
Use:
- read pointer
- write pointer
- modulo arithmetic
32. Implement your own realloc
Shrink/expand memory and copy old elements manually.
33. Implement memory-mapped register access (embedded C)
Simulate:
#define REG (*(volatile uint32_t*)0x40020000)
REG = 0xFF;
34. Demonstrate pointer aliasing problem
Write code where:
- two pointers refer to same memory
- updates cause unexpected behavior
35. Implement a hash table using pointers
Use:
- dynamic arrays
- linked list chaining
- pointer-to-pointer for insert
36. Implement function pointer table for drivers
Simulate operations struct:
struct ops { void (*init)(); void (*read)(); void (*write)(); };
37. Demonstrate dangling pointer
Step:
- allocate
- free
- access again
Then fix it.
38. Implement double-pointer dynamic 2D matrix
Manually allocate:
- row pointers
- each row
Print, free.
39. Implement triple pointer for 3D array
Show how int ***p manages a 3D matrix.
40. Implement pointer-based stack
Use dynamic memory + pointers for:
- push
- pop
50 Pointer Snippet Questions
Beginner Pointer Snippets
1.
int x = 10;
int *p = &x;
printf("%d", *p);
2.
int x = 5;
int *p = &x;
*p = 20;
printf("%d", x);
3.
int x = 10;
int *p = NULL;
printf("%p", p);
4.
int x = 10;
int *p = &x;
p++;
printf("%d", *p);
5.
int arr[] = {10,20,30};
int *p = arr;
printf("%d", *(p+1));
6.
char s[] = "Hello";
char *p = s;
printf("%c", *p++);
7.
int a = 10;
int b = 20;
int *p = &a;
p = &b;
printf("%d", *p);
8.
int *p;
int x = 10;
*p = x;
printf("%d", *p);
9.
int x = 10;
int *p = &x;
printf("%p %p", &x, p);
10.
int x = 10;
int *p = &x;
printf("%d", *p+2);
Intermediate Pointer Snippets
11.
int x = 5;
int *p = &x;
int **pp = &p;
printf("%d", **pp);
12.
int arr[] = {1,2,3,4};
int *p = arr+2;
printf("%d", p[-1]);
13.
char *p = "ABC";
printf("%c", *(p+2));
14.
int a = 5;
void *vp = &a;
printf("%d", *(int*)vp);
15.
int arr[3] = {10,20,30};
int (*p)[3] = &arr;
printf("%d", (*p)[1]);
16.
int *p = NULL;
printf("%d", *p);
17.
int a = 10, b = 20;
int *p1 = &a, *p2 = &b;
printf("%d", *p1 + *p2);
18.
int x = 10;
int *p = &x;
printf("%lu", sizeof(p));
19.
int x = 10;
int *p = &x;
int **pp = &p;
pp++;
printf("%p", *pp);
20.
int arr[] = {5, 10, 15};
int *p = arr;
printf("%d", ++*p);
Advanced Pointer Snippets
21.
char str[] = "ABCDE";
char *p = str;
printf("%c", ++*p);
22.
int a = 10;
int *p = &a;
*p = ++a;
printf("%d", a);
23.
int a = 10;
int *p = &a;
int *q = p;
*q = 100;
printf("%d", a);
24.
int arr[5] = {1,2,3,4,5};
int *p = arr;
printf("%d", *(p++) + *(++p));
25.
int x = 10;
int *p = &x;
printf("%d", *p++);
26.
char *p = "hello";
p[0] = 'H';
printf("%s", p);
27.
int a = 10;
int *p = &a;
printf("%d %d", a, *p);
a = 50;
printf("%d %d", a, *p);
28.
int arr[] = {10,20,30,40};
int *p = arr + 3;
printf("%d", p[-2]);
29.
void fun(int *p) { *p = 100; }
int x = 10;
fun(&x);
printf("%d", x);
30.
int *p = malloc(sizeof(int));
*p = 20;
printf("%d", *p);
free(p);
printf("%d", *p);
Deep Advanced & Tricky Snippets
31.
int a = 10;
int *p = &a;
*p = *p + (*p++);
printf("%d", a);
32.
int arr[] = {10,20,30,40};
int *p = arr;
printf("%d", *++p + ++*p);
33.
int x = 0;
int *p = &x;
if (p)
printf("Pointer is not NULL");
34.
int x = 10;
int y = 20;
int *p = &x;
*p = y;
printf("%d %d", x, y);
35.
int x = 5;
int *p = &x;
printf("%d", (++*p)++);
36.
int arr[] = {4,3,2,1};
int *p = arr;
printf("%d", *p + *(p+1) + *(p+2));
37.
int x = 5;
int *p = &x;
int **pp = &p;
**pp = 50;
printf("%d", x);
38.
char *s = "HELLO";
printf("%c", *s + 32);
39.
int a = 10;
int *p = &a;
printf("%d", *p + *(p));
40.
int x = 10;
int *p = &x;
printf("%p %p", p, &p);
Pointer + Function Snippets
41.
void fun(int *p) {
p = NULL;
}
int x = 10;
int *p = &x;
fun(p);
printf("%p", p);
42.
void fun(int **p) {
*p = NULL;
}
int x = 10;
int *p = &x;
fun(&p);
printf("%p", p);
43.
void fun(int *p) { *p = 200; }
int a = 10;
fun(&a);
printf("%d", a);
44.
void fun(int *p) { p++; }
int arr[] = {10,20,30};
int *p = arr;
fun(p);
printf("%d", *p);
45.
void fun(int p) { p = 100; }
int x = 10;
fun(x);
printf("%d", x);
46.
int fun() { return 5; }
int (*fp)() = fun;
printf("%d", fp());
47.
int add(int a, int b) { return a+b; }
int (*fp)(int,int) = add;
printf("%d", fp(5,6));
48.
int arr[] = {1,2,3};
int *p = arr;
printf("%d", (*p)++);
49.
int x = 10;
int *p = &x;
printf("%d", ++(*p));
50.
int arr[3] = {1,2,3};
int *p = arr;
printf("%d", *p + *(p+2));
When it comes to mastering ESP microcontrollers, developers often struggle to find a single place where everything from basics to advanced real-world projects—is explained clearly.
That’s why resources like Embedded Prep Master have become extremely valuable for students, embedded engineers, and hobbyists.
One of the best guides available today is:
Complete ESP Tutorials (Beginner to Advanced) : ESP32 Tutorials
This guide is a complete gateway for anyone who wants to learn ESP32, ESP8266, IoT development, sensor interfacing, Wi-Fi programming, and real embedded-system projects.
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.











