Below are 5 questions to practice for C interview questions. These are from diverse topics.
Can you explain the difference between data types and modifiers?
Data types are the ones including int, float, char, double that determine the type and storage of the data within the variables. Whereas modifiers are used in conjunction with data types to precisely control the amount of storage to a variable of a particular data type. short, long etc are modifiers.
Is it possible to precisely tell the size of short int in any machine?
This depends upon the implementation. Guideline from ANSI C on the size of short int is that the size of short int should be lesser than or equal to than that of int.
Does C have automatic garbage collection? What this can lead to?
C does not have automatic garbage collection. In worst cases, this can lead to a memory leak. Memory leak occurs when dynamically allocated memory is not available for reuse.
Tell a common mistake that programmers often do when using a new variable as counter for FOR loops? What could be a simple preventive measure?
When using a new variable, some programmers tend to forget the initialization part. There could be several preventive measures. One measure could be that programmer can consider declaring two or three extra variables which can be used for future FOR loops as and when required.
What is a recursive function? Which are the two ways by which recursive programs can be stopped?
A function calling itself is called a recursive function. As expected, there is a danger of these functions running indefinitely. However practically that is not the case. They get stopped either
Programmatically (programmer checks certain condition and instructs exit) Or the program itself will crash due to stack overflow after certain high number of function calls.