FreeJobAlert.Com

Government Jobs | Results | Admit Cards

Advertisement

c language interview questions | Part 11

If you would like to view All C language interview questions only at one place visit below link
All C Language Interview Questions

101. IMP>Can we initialize unions?
Ans: ANSI Standard C allows an initializer for the first member of a union. There is no standard way
of initializing any other member (nor, under a pre-ANSI compiler, is there generally any way of
initializing a union at all).

102. What’s the difference between these two declarations?
Ans: struct x1 { … };
typedef struct { … } x2;
The first form declares a structure tag; the second declares a typedef. The main difference is that the second declaration is of a slightly more abstract type.its users don’t necessarily know that it is a structure, and the keyword struct is not used when declaring instances of it.

103. 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.

104.WHy doesn’t struct x { … };
x thestruct;
work?

Ans:
C is not C++. Typedef names are not automatically generated for structure tags.

105. 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.

106. How are structure passing and returning implemented?
Ans: When structures are passed as arguments to functions, the entire structure is typically pushed on
the stack, using as many words as are required. Some compilers merely pass a pointer to the structure, though they may have to make a local copy to preserve pass-by-value semantics.
Structures are often returned from functions in a location pointed to by an extra,compiler-supplied “hidden” argument to the function. Some older compilers used a special,static location for structure returns, although this made structure-valued functions non-reentrant, which ANSI C disallows.

Related Fresher Interview Questions

1. C Language Interview Questions
2. C++ Language Interview Questions
3. Data Structures Interview Questions
4. DBMS Interview Questions
5. Operating System Interview Questions
6. UNIX Interview Questions

Tags: c fresher interview questions, c interview, c interview questions, c interview questions and answers, c interview questions and answers for freshers, c interview questions for freshers, c interview questions with answers, c language interview questions, c language interview questions and answers, fresher interview questions, fresher interview questions and answers, fresher interview questions and answers on c, fresher interview questions on c, fresher interview questions with answers, interview questions on c, it fresher interview questions, it fresher interview questions and answers, questions for interview, questions on c

Responses to “c language interview questions | Part 11”

  1. Yes. Its really helps lot to us. Thank u

Leave a Comment