C Language Interview Question and Answers
61. |
What is dynamic array? |
|
The dynamic array is an array data structure which can be resized during runtime which means elements can be added and removed. |
|
|
62. |
What are macros? What are its advantages and disadvantages? |
|
Macros are abbreviations for lengthy and frequently used statements. When a macro is called the entire code is substituted by a single line though the macro definition is of several lines. The advantage of macro is that it reduces the time taken for control transfer as in case of function. The disadvantage of it is here the entire code is substituted so the program becomes lengthy if a macro is called several times. |
|
|
63. |
What is a copy constructor and when is it called? |
|
A copy constructor is a method that accepts an object of the same class and copies it members to the object on the left part of assignement. |
|
|
64. |
Where is the auto variables stored? |
|
Auto variables can be stored anywhere, so long as recursion works. Practically, they’restored on the stack. It is not necessary that always a stack exist. You could theoretically allocate function invocation records from the heap. |
|
|
65. |
What is the difference between arrays and linked list? |
|
- An array is a repeated pattern of variables in contiguous storage.
- A linked list is a set of structures scattered through memory, held together by pointers in each element that point to the next element. With an array, we can (on most architectures) move from one element to the next by adding a fixed constant to the integer value of the pointer.
- With a linked list, there is a “next” pointer in each structure which says what element comes next.
|
|
|