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 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.

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,
- The “ptr” is a constant integer.
- Here “ptr” is a pointer to a const integer, the value of the integer is not modifiable, but the pointer is not modifiable.
- 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.
- 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.