C Pointer Interview Questions and Answers

What is a Pointer ?
A derived data type used to store address(memory location)

What is the use of Pointer variable ?
Used to access the information by holds its address.
It is also called in-direction operator.

What is the size of pointer ?
size of pointer is equals to size of integer on the machine.
On 16 bit compiler, pointer size is 2 bytes.

What is void pointer ?
void* is called Generic pointer.
void* variable can holds any pointer type value.

What is Call by Value ?
Calling a function by passing values as parameters is called Call by Value.

What is Call by Reference?
Calling a function by passing address(reference) as parameter. We collect these addresses into
pointer type variables in the called function.

What pointer operator(*) returns ?
Pointer operator returns the data of specified memory location.

Can we create a pointer to function ?
Functions execute at a particular memory location is called FRAME.
Every FRAME has a address.
Pointer to function variable holds that address to execute function.

How to declare pointer to function ?
Pointer to function declaration depends on the prototype of function.
syntax :
return_type (*identifier) (arguments_list) ;

What is Dangling pointer ?
Declaration of pointer variable that holds the address of local variable of another function.

What is pointer casting ?
Converting one typed pointer to another typed pointer to make it pointing to another type of data.

What is pointer arithmetic ?
When we modify the pointer variable, the size of pointer increases/decreases by size bytes of data
which is currently pointing to.

Can we apply modify operators on pointer variable ?
Yes we can.
Using modify operators only we can process array elements effectively.

Define Array of Pointers ?
Array of Pointers means an Array which is holding
1) References of same array elements
2) Reference of different array elements

What is the use of Array of Pointers ?
We can easily process the information like Set of String elements and to process multi dimensional
array data.

Can we create pointer to Structure?
Yes.
When a pointer is pointing to structure, we use Arrow(->) operator to access the elements of
structures instead of dot(.) operator.

How to access structure elements using pointer ?
Using Arrow(->) operator.
Generally we use dot(.) operator to access structure elements.

What char* represents in C ?
char* can points
1) a single character
2) array of characters(string)

Can a function returns Array using pointers ?
Yes. A function can returns array only by using pointers.
A function can return address so that return type is pointer type.

Can a function returns String using char* ?
Yes, we can return Strings from functions only by returns base address of that String.

What is the use of Pointer to Pointer ?
Easily we can process the elements which are connected.
for example Linked Lists.

Describe this pointer declaration ?
​int (* ptr) (int,int)
“ptr” is a pointer, pointing to a function which is taking 2 integer arguments and returns integer data.

Describe this pointer declaration ?
char (* ptr) [3]
“ptr” is a pointer pointing to array of size is 3 and the array is holding character elements.

Describe this pointer declaration ?
​int ( * ( * ptr ) [ 5 ] ) ( )
“ptr” is pointer variable which is pointing to an array which is holding address of 5 functions and each
function is not taking input but returns integer.

 

>C Language Basic Interview Questions<

Share this