C Language Interview Questions & Answers

Showing 10 of 130 questions

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

1. How do you decide which integer type to use?

If you might need large values (tens of thousands), use long.Otherwise, if space is very important, use short. Otherwise,use int.

2. What should the 64-bit type on new, 64-bit machines be?

There are arguments in favor of long int and long long int,among other options.

3. What's the best way to declare and define global variables?

The best arrangement is to place each definition in some relevant .c file, with an external declaration in a header file.

4. What does extern mean in a function declaration?

Nothing, really.

5. What's the auto keyword good for?

Nothing.

6. I can't seem to define a linked list node which contains a pointer to itself.

Structures in C can certainly contain pointers to themselves;the discussion and example in section 6.5 of K&R make this clear. Problems arise if an attempt is made to define (and use) a typedef in the midst of such a declaration; avoid this.

7. How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

char *(*(*a[N])())(); Using a chain of typedefs, or the cdecl program, makes these declarations easier.

8. How can I declare a function that returns a pointer to a function of its own type?

You can't quite do it directly. Use a cast, or wrap a struct around the pointer and return that.

9. My compiler is complaining about an invalid redeclaration of a function, but I only define it once.

Calling an undeclared function declares it implicitly as returning int.

10. What can I safely assume about the initial values of variables which are not explicitly initialized?

Uninitialized variables with "static" duration start out as 0,as if the programmer had initialized them. Variables with "automatic" duration, and dynamically-allocated memory, start out containing garbage (with the exception of calloc).
Questions and Answers for Competitive Exams Various Entrance Test