101. Are the variables argc and argv are always local to main?
Ans: Yes they are local to main.
102. Why doesn’t this code: a[i] = i++; work?
Ans: The subexpression i++ causes a side effect.it modifies i’s value.which leads to undefined
behavior since i is also referenced elsewhere in the same expression.
103.WHy doesn’t struct x { … };
x thestruct;
Ans: Yes they are local to main.
102. Why doesn’t this code: a[i] = i++; work?
Ans: The subexpression i++ causes a side effect.it modifies i’s value.which leads to undefined
behavior since i is also referenced elsewhere in the same expression.
103.WHy doesn’t struct x { … };
x thestruct;
Advertisement
103. work?
Ans: C is not C++. Typedef names are not automatically generated for structure tags.
104. Why can’t we compare structures?
Ans: There is no single, good way for a compiler to implement structure comparison which is consistent with C’s low-level flavor. A simple byte-by-byte comparison could founder on random bits present in unused “holes” in the structure (such padding is used to keep the alignment of later fields correct). A field-by-field comparison might require unacceptable amounts of repetitive code for large structures.
Ans: C is not C++. Typedef names are not automatically generated for structure tags.
104. Why can’t we compare structures?
Ans: There is no single, good way for a compiler to implement structure comparison which is consistent with C’s low-level flavor. A simple byte-by-byte comparison could founder on random bits present in unused “holes” in the structure (such padding is used to keep the alignment of later fields correct). A field-by-field comparison might require unacceptable amounts of repetitive code for large structures.
Advertisement
105. Represent a two-dimensional array using pointer?
Ans: Address of a[I][j] Value of a[I][j]
&a[I][j]
or
a[I] + j
or
*(a+I) + j
*&a[I][j] or a[I][j]
or
*(a[I] + j )
or
*( * ( a+I) +j )
106. Difference between arrays and linked list?
Ans: 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.
107. What does static variable mean?
Ans: Static variables are the variables which retain their values between the function calls. They are initialized only once their scope is within the function in which they are defined.
Ans: Address of a[I][j] Value of a[I][j]
&a[I][j]
or
a[I] + j
or
*(a+I) + j
*&a[I][j] or a[I][j]
or
*(a[I] + j )
or
*( * ( a+I) +j )
106. Difference between arrays and linked list?
Ans: 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.
107. What does static variable mean?
Ans: Static variables are the variables which retain their values between the function calls. They are initialized only once their scope is within the function in which they are defined.