C Language Interview Questions & Answers

Showing 10 of 130 questions | Page 5

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

41. Does *p++ increment p, or what it points to?

*p++ increments p. To increment the value pointed to by p, use (*p)++ .

42. I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.

The called function probably altered only the passed copy of the pointer.

43. I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?

You will have to declare a temporary variable.

44. Does C even have "pass by reference"?

Not really, though it can be simulated.

45. I've seen different methods used for calling functions via pointers

The extra parentheses and explicit * are now officially optional, although some older implementations require them.

46. What is this infamous null pointer, anyway?

For each pointer type, there is a special value -- the "null pointer" -- which is distinguishable from all other pointer values and which is not the address of any object or function.

47. How do I get a null pointer in my programs?

A constant 0 in a pointer context is converted into a null pointer at compile time. A "pointer context" is an initialization, assignment, or comparison with one side a variable or expression of pointer type, and (in ANSI standard C) a function argument which has a prototype in scope declaring a certain parameter as being of pointer type. In other contexts (function arguments without prototypes, or in the variable part of variadic function calls) a constant 0 with an appropriate explicit cast

48. Is the abbreviated pointer comparison "if(p)" to test for non-null pointers valid?

Yes. The construction "if(p)" works, regardless of the internal representation of null pointers, because the compiler essentially rewrites it as "if(p != 0)" and goes on to convert 0 into the correct null pointer.

49. What is NULL and how is it #defined?

NULL is simply a preprocessor macro, #defined as 0 (or ((void *)0)), which is used (as a stylistic convention, in preference to unadorned 0's) to generate null pointers.

50. How should NULL be defined on a machine which uses a nonzero bit pattern as the internal representation of a null pointer?

The same as on any other machine: as 0 (or ((void *)0)). (The compiler makes the translation, upon seeing a 0, not the preprocessor.
Questions and Answers for Competitive Exams Various Entrance Test