C Language Interview Questions & Answers

Showing 10 of 130 questions | Page 2

Technical interview questions and answers are essential for clearing a C Language Interview because C is the foundation of all modern programming languages. C interviews typically include questions related to pointers, loops, functions, arrays, memory allocation, structures, and file handling. Whether you are preparing for campus placements or software development roles, companies such as TCS, Wipro, Infosys, Cognizant, and Accenture frequently test your C programming basics. This guide includes the most frequently asked C Language interview questions with clear explanations to help freshers and job seekers build strong conceptual understanding. Learning these questions will help you perform confidently in coding rounds, written tests, and technical interviews.

C programmers should advance their skills by learning C++ programming  and mastering data structures  for algorithm development 

Showing 10 of 130 questions

11. Why can't I initialize a local array with a string?

Perhaps you have a pre-ANSI compiler.

12. What's wrong with "char *p = malloc(10);" ?

Function calls are not allowed in initializers for global or static variables.

13. What is the difference between char a[] = "string"; and char *p = "string"; ?

The first declares an initialized and modifiable array; the second declares a pointer initialized to a not-necessarily-modifiable constant string.

14. How do I initialize a pointer to a function?

Use something like "extern int func(); int (*fp)() = func;"

15. What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?

The first structure is named by a tag, the second by a typedef name.

16. What's the best way of implementing opaque (abstract) data types in C?

One good way is to use structure pointers which point to structure types which are not publicly defined.

17. I came across some code that declared a structure with the last member an array of one element, and then did some tricky allocation to make it act like the array had several elements.Is this legal or portable?

An official interpretation has deemed that it is not strictly conforming with the C Standard.

18. Why can't you compare structures?

There is no single, good way for a compiler to implement structure comparison which is consistent with C's low-level flavor.

19. How are structure passing and returning implemented?

If you really need to know, see the unabridged list.

20. Can I pass constant values to functions which accept structure arguments?

No. C has no way of generating anonymous structure values.
Questions and Answers for Competitive Exams Various Entrance Test