Top

C Programming

41.

What is the meaning of base address of the array?

Ans:

The starting address of the array is called as the base address of the array.

42.

What is /0 character?

Ans:

The Symbol mentioned is called a Null Character. It is considered as the terminating character used in strings to notify the end of the string to the compiler.

43.

What is a pointer in C?

Ans:

A pointer is a variable that refers to the address of a value. It makes the code optimized and makes the performance fast. Whenever a variable is declared inside a program, then the system allocates some memory to a variable. The memory contains some address numbers. The variable that hold this address number is known as the pointer variable.

Data_type *p;

 

44.

What is the usage of the pointer in C?

Ans:

  • Accessing array elements: Pointers are used in traversing through an array of integers and strings. The string is an array of characters that is terminated by a null character '\0'.
  • Dynamic memory allocation: Pointers are used in the allocation and deallocation of memory during the execution of a program.
  • Call by Reference: The pointers are used to pass a reference of a variable to another function.
  • Data Structures like a tree, graph, linked list, etc.: The pointers are used to construct different data structures like trees, graphs, linked lists, etc.

 

45.

What is a NULL pointer in C?

Ans:

A pointer that doesn't refer to any address of value but NULL is known as a NULL pointer. When we assign a '0' value to a pointer of any type, then it becomes a Null pointer.

46.

What is a far pointer in C?

Ans:

A pointer that can access all the 16 segments (whole residence memory) of RAM is known as a far pointer. A far pointer is a 32-bit pointer that obtains information outside the memory in a given section.

47.

What is dangling pointer in C?

Ans:

If a pointer is pointing to any memory location, but meanwhile another pointer deletes the memory occupied by the first pointer while the first pointer still points to that memory location, the first pointer will be known as a dangling pointer. This problem is known as a dangling pointer problem.

A dangling pointer arises when an object is deleted without modifying the value of the pointer. The pointer points to the deallocated memory.

48.

What is pointer to pointer in C?

Ans:

In the case of a pointer to pointer concept, one pointer refers to the address of another pointer. The pointer to pointer is a chain of pointers. Generally, the pointer contains the address of a variable. The pointer to pointer contains the address of a first pointer. Let's understand this concept through an example:

#include   
 int main()  
{  
    int a=10;  
    int *ptr,**pptr; // *ptr is a pointer and **pptr is a double pointer.  
    ptr=&a;  
    pptr=&ptr;  
    printf("value of a is:%d",a);  
    printf("\n");  
    printf("value of *ptr is : %d",*ptr);  
    printf("\n");  
    printf("value of **pptr is : %d",**pptr);  
    return 0;  
}

In the above example, pptr is a double pointer pointing to the address of the ptr variable, and ptr points to the address of the 'a' variable.

49.

What is a constant pointer?

Ans:

A pointer which is not allowed to be altered to hold another address after it is holding one.

50.

What is the difference between near, far, and huge pointers?

Ans:

A virtual address is composed of the selector and offset.

A near pointer doesn't have an explicit selector whereas far, and huge pointers have an explicit selector. When you perform pointer arithmetic on the far pointer, the selector is not modified, but in the case of a huge pointer, it can be modified.

These are the non-standard keywords and implementation-specific. These are irrelevant in a modern platform.

Loading…
Tags: C Programming Interview Questions and Answers || C Programming Sort Questions and Answers || C Programming Detailed Questions and Answers || C Programming Tutorial