Skip to main content

C Programming Interview Questions With Answers - Part XIII.


104. What Is A Near Pointer?

Answer: A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the data/code to 64KB segment.


105. How Many Bytes Are Occupied By Near, Far & Huge Pointers?

Answer: The near pointer is 2 bytes long and far and huge pointers are 4 bytes long.


106. What Are Dangling Pointers?

Answer: Dangling pointer is a concept which results when you have a pointer pointing to a location in memory that is meaningless. For example, consider the function

void DanglingPointer(int *x)
{
int y=0;
x = &y;
return;
}

When the function is called, space is allocated for the variable y on the stack, and the pointer x contains the address of that space. But when the function returns control to the calling function, the space that was allocated for y is cleared and x points to a meaningless location in memory


107. What Is A NULL Pointer? Whether It Is Same As An Uninitialized Pointer? What Does The Error ‘Null Pointer Assignment’ Means & What Causes This Error?

Answer: Null pointer is a pointer which points to nothing but uninitialized pointer may point to anywhere.

As null pointer points to nothing so accessing an uninitialized pointer or invalid location may cause an error.


108. Are Pointers Integer?

Answer: No, pointers are not integers. A pointer is an address. It is a positive number.


109. What Is Generic Pointer In C?

Answer: In C void* acts as a generic pointer. When other pointer types are assigned to generic pointer, conversions are applied automatically (implicit conversion).


110. How Pointer Variables Are Initialized?

Answer: Pointer variables are initialized by one of the following ways.
  • Static memory allocation.
  • Dynamic memory allocation.

111. What Is Pointer To A Pointer?

Answer: If a pointer variable points another pointer value. Such a situation is known as a pointer to a pointer. Example:

int *p1,**p2,v=10;
p1=&v;
p2=&p1;
Here p2 is a pointer to a pointer.


112. What Is An Array Of Pointers?

Answer: If the elements of an array are addresses, such an array is called an array of pointers.


113. Difference Between Array & Pointer?

Answer: Differences between array and pointers are:
  • Array allocates space automatically whereas pointer is explicitly assigned to point to an allocated space.
  • Arrays cannot be re-sized whereas pointers can be  sized using realloc().
  • Arrays cannot be reassigned whereas Pointer can be reassigned.
  • sizeof (array name) gives the number of bytes occupied by the array whereas Sizeof (p) returns the number of bytes used to store the pointer variable p.

114. What Are References. State The Differences Between Reference & Pointer.

Answer: Like a pointer, a reference is an alias for an object (or variable), is usually implemented to hold a machine address of an object (or variable), and does not impose performance overhead compared to pointers.

The notation X& means "reference to X".

Differences between reference and pointer are:
  • A reference can be accessed with exactly the same syntax as the name of an object.
  • A reference always refers to the object to which it was initialized.
  • There is no “null reference”, and we may assume that a reference refers to an object.

Two things to note on references:
  • One cannot have a pointer to a reference.
  • One cannot define an array of references.


Also Read The Following Questions:

66) Difference between array and pointer?
67) Difference between a array name and a pointer variable?
68) Difference between an array of pointers and a pointer to an array?
69) What are the pointer declarations used in C?
70) Differentiate between a constant pointer and pointer to a constant?


71) What is the invalid pointer arithmetic?
72) What are the advantages of using array of pointers to string instead of an array of strings?
73) Are the expressions *ptr ++ and ++ *ptr same?


...Return To C Questions INDEX.

...Return To C Programming INDEX.


... Return To HR Interview Index

Comments

Popular posts from this blog

Tell Me Something About Yourself - Interview Answers.

Try to introduce some of your most important employment-oriented skills as well as your education and accomplishments to the interviewer. Answer to this question is very important because it positions you for the rest of the interview . That's why this statement is often called the "Positioning Statement". One should take the opportunity to show his/her communication skills by speaking clearly and concisely in an organized manner. Since there is no right or wrong answer for this question hence it is important to appear friendly. YOUR ANSWERS CAN BE: 1) I am a person with strong interpersonal skills and have the ability to get along well with people . I enjoy challenges and looking for creative solutions to problems. 2) Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies apti...

HR Interview Questions With Simple Answers - Top 30.

Here are some very important HR questions which are often asked during Interviews and I believe these answers can really help you to get through....... Click on them to view the answer: 1) Tell Me Something About Yourself ? 2) What Are Your Strengths? 3) What Are Your Weaknesses? 4) How Do You Handle Pressure / Can You Work Well Under Pressure? 5) What Are Your Short Term Goals? 6) What Are Your Long Term Goals? 7) Where Do You See After 5 Years? 8) Why Should We Hire You? 9) What Is Your Salary Expectation? 10) Why Do You Want To Leave Your Current Job? 11) Do You Prefer To Work Alone Or As A Team Player? 12) What Made You Choose Your Major / Stream? 13) Why Didn’t You Pursue A Career In Your Major / Stream? 14) Why Do You Want To Work For Us? 15) Are You Willing To Travel? 16) Are You Willing To Take Risks? 17) What Do You Know About This Company? 18) What Do You Seek From A Job? 19) How Do You Evaluate Success? 20) Dur...

Sample Cover Letter / Job Application.

To The General Manager (HR) [ Name and Designation (Bold Words)] Infosys Limited Delhi – 110001 Uttam Agrawal Gandhi Chowk, Bhartee Street [ Name Bhawanipatna, Kalahandi Contact Address Orissa – 766001 Telephone No.] Ph. no - +91-9438170446 [Sub: Application for the position of ___________ in your esteemed organization.] Respected Sir, (Always use ‘Respected’) With reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ___________ . I would like to place myself as a strong contender before you. OR This has reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ____________. In the said connection I take this opportunity to apply for the said position as a strong contender. /*This is the Introduction i.e the first paragraph of your application/* ( Now the Second Paragraph is the Self Introduction) Try to start the second paragraph with the below mentioned lines: - I have the p...