Table of contents
1.
Introduction
2.
Pointers interview questions for Freshers
2.1.
1. What is a pointer?
2.2.
2. Describe the usage of pointers in C.
2.3.
3. What is a Null Pointer?
2.4.
4. How can you combine the following two statements into one?
2.5.
5. What is the size of a generic pointer?
2.6.
6. What is a dangling pointer in C?
2.7.
7. What is a generic pointer? When can we use a generic pointer?
2.8.
8. Explain the term double-pointer.
2.9.
9. What is a wild pointer?
2.10.
10. Explain near, far, and huge pointers?
2.11.
11. What is the difference between a null pointer and an uninitialized pointer?
2.12.
12. Explain the meaning of the below declarations?
2.13.
13. What does it mean when a pointer is used inside an if statement?
2.14.
14. What is Dereference or Indirection Operator ( * )?
2.15.
15. How do you dereference a pointer?
3.
Pointers interview questions for Experienced
3.1.
16. How many pointers can point to the same address?
3.2.
17. Where is the pointer variable stored in memory?
3.3.
18. What is an array of pointers?
3.4.
19. How is a dangling pointer different from a memory leak?
3.5.
20. What do you mean by the pointer to a function?
3.6.
21. What will be the output of the C program?
3.7.
22. Fill the question mark to get "10" as an output?
3.8.
23. Which type of pointer is the most convention way of storing the raw address in c programming?
3.9.
24.  What will be the output of the C program?
3.10.
25. What will be output of following program?
3.11.
26. What will be printed as the result of the operation below?
3.12.
27. What will be output of following program?
3.13.
28. State the equivalent pointer expression which refer the given array element arr[i][j][k][l]?
3.14.
29. Fill the question mark to get "void pointer" as an output?
3.15.
30. What is the output of the below program? The assumed size of char, int, and double is 1,4,8.
4.
Frequently Asked Questions
4.1.
What is the difference between arrays and pointers?
4.2.
Is the pointer faster than the array?
4.3.
What is the maximum level that we can create for pointer to pointer?
5.
Conclusion
Last Updated: Dec 26, 2024
Medium

Top 30 Pointers interview questions & Answers (2025)

Author Divyanshi Yadav
2 upvotes
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

The most challenging and complex component of C programming is pointers. Understanding the concept of a pointer is vital because it works directly on address locations, giving you a complete picture of how computer memory addressing works. Many MNCs have also asked such pointers interview questions in their assessment rounds. So, without any further wait, let's delve straight into these pointers interview questions that are prepared to help you understand the basic concept of pointers and their associated keywords.

Pointers interview questions

Pointers interview questions for Freshers

1. What is a pointer?

This is said to be a very basic pointer interview question. Pointer is a variable that stores the address of another variable. The syntax of a pointer is represented as 

Data_Type * Pointer_Name;

 

An example to understand this syntax:

int *ptr;

 

Here, the ptr is an integer type of pointer.

pointers

2. Describe the usage of pointers in C.

Some of the areas where pointers are used are:

  • To access array elements
  • Used to return multiple values
  • Used in Dynamic memory Allocation
  • To pass arguments by reference
  • Reduces the execution time of the program
  • Pointers help us to build complex data structures like a linked list, stack, queues, trees, and graphs.

 

3. What is a Null Pointer?

A null reference or null pointer is a value saved for indicating that the reference or pointer does not refer to a valid object. They can be used to stop indirection in a recursive Data Structure, as an error value or as a sentinel value.

 

4. How can you combine the following two statements into one?

char *pointer;
pointer = (char*)malloc(100);

 

It can be combined as: char *pointer = (char*)malloc(100);

 

5. What is the size of a generic pointer?

For a system of 16-bit, the size of a generic pointer is 2 bytes. If the system is 32-bit, the size of a generic pointer is 4 bytes. If the system is 64-bit, the size of a generic pointer is 8 bytes.

 

6. What is a dangling pointer in C?

Ans: A pointer pointing to a non-existing memory location is a dangling pointer. A dangling pointer is a pointer that has a value (not NULL) which refers to some memory that is not valid or does not exists.

 

7. What is a generic pointer? When can we use a generic pointer?

When a variable is declared void type it is known as a  generic pointer. It is a pointer that can point to any data. They are used when we want to return such a pointer which applies to all types of pointers. They can also be used to increase the re-usability of the pointer. 

 

8. Explain the term double-pointer.

If a pointer holds another pointer's address, then such pointer is known as double-pointer or pointer-to-pointer.

For example, 

int **point;

 

Here, the point is a double-pointer.

 

9. What is a wild pointer?

A pointer that is not initialized properly before its first use is known as the wild pointer. They are called so because the uninitialized pointer’s behavior is undefined as it may point to some arbitrary location that can cause the program to crash. Generally, compilers warn about the wild pointer.

 

10. Explain near, far, and huge pointers?

A far pointer is of size 32 bit, which includes a segment selector, making it possible to point the addresses outside of the default segment.

Near pointer is utilized for storing 16-bit addresses means within the current segment on a 16-bit machine. The drawback is that we can only access 64kb of data each time.

The huge pointer is also 32-bit and can access outside segments. In the far pointer, Huge can be changed but the segment part cannot be changed.

 

11. What is the difference between a null pointer and an uninitialized pointer?

An uninitialized pointer is one that points to a memory location that isn't known. If we try to dereference the uninitialized pointer, code behavior will be undefined. 

According to C standard, an integer constant expression having the value 0, or such an expression cast to type void *, is known as a null pointer constant. If you try to dereference the null pointer then your code will crash.

 

12. Explain the meaning of the below declarations?

1. const int ptr;
2. const int *ptr;
3. int * const ptr;
4. int const * a const;

 

Here,

  1. The “ptr” is a constant integer.
  2. Here “ptr” is a pointer to a const integer, the value of the integer is not modifiable, but the pointer is not modifiable.
  3. Here “ptr” is a constant pointer to an integer which means that the value of the pointed integer is changeable, but the pointer is not modifiable.
  4. Here “a” is a const pointer to a const integer which means the value of the pointed integer and pointer both cannot be changed.


Check this out, include stdio h

13. What does it mean when a pointer is used inside an if statement?

A pointer can be used in an for, if, while, or do/while statement, or in any conditional expression. It prevents code from crashing.

For example:

if ( condition is true )
{
   /*Run when valid address */
}
else
{
   /*When NULL pointer*/
}

 

14. What is Dereference or Indirection Operator ( * )?

Dereference operator is a unary operator that is used in the declaration of the pointer and accesses a value indirectly, through a pointer. The operand of such operator should be a pointer and the result of the operation is value addressed by the operand (pointer).

For example,

int *iPointer; // Use of indirection operator in the declaration of pointer
a = *iPointer; //Use of indirection operator to read the value of the address pointed by the pointer
*iPointer = a; //Use of indirection operator to write the value to the address pointed by pointer.

 

15. How do you dereference a pointer?

The operator * is used to do this, and is called the dereferencing operator. Dereferencing a pointer means getting the value, stored in the memory location pointed by the pointer. For example, 

int a=5;
int* p=&a;
printf(“%d”,*p); //dereferencing the pointer p.

 

Pointers interview questions for Experienced

16. How many pointers can point to the same address?

Multiple pointers can point to the same memory address.

 

17. Where is the pointer variable stored in memory?

Pointer variables are stored in stack memory.

 

18. What is an array of pointers?

It is an array of the pointer variables. It is also known as pointer arrays. 

Declaration:

data_type *name_of_array[array_size];

 

Example:

int *a[5];

 

Here “a” is an array of  5 integer pointers.

 

19. How is a dangling pointer different from a memory leak?

A dangling pointer points to a memory location that has been freed or deleted.

Contrary to the dangling pointer, a memory leak occurs when we forget to de-allocate the allocated memory.

 

20. What do you mean by the pointer to a function?

A pointer to a function points to the address of the executable code of the function. We can use pointers to call and pass functions as arguments to other functions. The type of a pointer to a function is based on both parameter types and the function's return type.

Read more: System Design Interview Questions

 

21. What will be the output of the C program?

#include<stdio.h>
int main(){
 int i = 5;
 void *ptr; 
 ptr = &i;
 printf("\nValue of iptr = %d ", *ptr);
 return 0;
}
You can also try this code with Online C Compiler
Run Code

It will give garbage value as void type cannot be dereferenced without typecasting.

 

22. Fill the question mark to get "10" as an output?

#include<stdio.h>
int main()
{
 int i = 10,*ptr;
 ptr= &i;
 void *vptr; 
 vptr = &ptr;
 printf("\nValue of iptr = %d ", ?);
 return 0;
}
You can also try this code with Online C Compiler
Run Code

 

 **(int **)vptr

 

23. Which type of pointer is the most convention way of storing the raw address in c programming?

Ans: Void pointer is the most conventional way because void pointer does not have any associated data type. As the void pointer is generic, it can store the raw address of a variable irrespective of its data type.

 

24.  What will be the output of the C program?

#include<stdio.h>
#define NULL "error";
int main()
{
 char *ptr = NULL;
 printf("%s",ptr);
 return 0;
}
You can also try this code with Online C Compiler
Run Code

 

It will give an error as NULL is used for the stylistic convention. Thus NULL itself is a macro that is defined in #include<stdio.h> header files, thus modifying the macro cause no error. Such output questions are important for pointers interview questions. Now lets look at some more of these pointers interview questions.

 

25. What will be output of following program?

#include<stdio.h>
int main() {
int a = 10;
void *p = &a;
int *ptr = p;
printf(“%u”,*ptr);
return 0;
}
You can also try this code with Online C Compiler
Run Code

 

Output

10

It's because void can hold the address of any data type without type casting. Any Pointer can hold void pointer without type casting.

 

26. What will be printed as the result of the operation below?

#include<stdio.h>
int main()
{
char *p1;
char *p2;
p1=(char*)malloc(25);
p2=(char*)malloc(25);
strcpy(p1,”Coding”);
strcpy(p2,”Ninjas”);
strcat(p1,p2);
printf(“%s”,p1);
}
You can also try this code with Online C Compiler
Run Code

 

Output : CodingNinjas

The above operation can combine the two strings. A concatenation operation will be performed.

 

27. What will be output of following program?

#include<stdio.h>
int main() {
int a = 5,b = 10,c;
int *p = &a,*q = &b;
c = p-q;
printf(“%d”,c);
return 0;
}
You can also try this code with Online C Compiler
Run Code

 

Output

1

The difference between the two same types of pointers is always one.

 

28. State the equivalent pointer expression which refer the given array element arr[i][j][k][l]?

Ans: Above pointer expression can be written as *(*(*(*(arr+i)+j)+k)+l).

 

29. Fill the question mark to get "void pointer" as an output?

#include<stdio.h>
int main(){
 char *ptr = "void pointer";
 void *vptr;
 vptr = &ptr;
 printf("%s" , ?);
 return 0;
}
You can also try this code with Online C Compiler
Run Code

 

*(char **)vptr

In this program, we used a void pointer to display the string stored in another char pointer variable. Thus by using pointer to pointer typecasting *(char **)vptr we have output the string "void pointer".

 

30. What is the output of the below program? The assumed size of char, int, and double is 1,4,8.

#include<stdio.h>
int main()
{
   int a, b, c;
   char *p = 0;
   int *q = 0;
   double *r = 0;
   a = (int)(p + 1);
   b = (int)(q + 1);
   c = (int)(r + 1);
   printf("%d %d  %d",a, b, c);
   return 0;
}
You can also try this code with Online C Compiler
Run Code

 

Output

1,4,8

Frequently Asked Questions

What is the difference between arrays and pointers?

This is one of the most frequently asked pointers interview question. Arrays are used to store elements of same types whereas Pointers are address variables that store the address of a variable. 

Is the pointer faster than the array?

Arrays will always be faster as memory allocation of an array is continuous. So accessing an array is much faster compared to a pointer where memory allocation might or might not be continuous.

What is the maximum level that we can create for pointer to pointer?

The maximum level of pointers to pointers that you can create in C or C++ is determined by the memory limitations of the system. Each level of indirection adds another layer of memory address resolution.

Conclusion

The article discussed frequently asked Pointers interview questions for students asked in job interviews. Once you are done with these pointers interview questions, you may check out our article C# interview questions for 5 years Experience to level up your programming journey and get placed at your dream company. 
Explore more interview questions related articles:

Live masterclass