C Interview Questions Download PDF

1 . What are the key features of C programming language?

C is a platform-dependent language. C offers the possibility to break down a large program into small modules. Also, the possibility of a programmer to control the language. C comes with support for system programming and hence it compiles and executes with high speed when compared to other high-level languages.


2 . What is the use of header files in C?

Header files contain the definitions and set of rules of the functions being used in the programs. For example, when you use printf() or scanf() in your program, you nee to include stdio.h library function. Else your compiler will show an error. This is because, the standard input and output functions printf() and scanf() are stored in this header file. So similarly every header file stores a set of predefined functions which makes it easy to program.


3 . What is Memory Leak in C?

A memory leak occurs when programmers create a memory in the heap and forget to delete it. It decreases the efficiency of the performance of the system.


4 . What is the difference between ++a and a++?

‘++a’ is called prefix increment. First, the value stored in the variable ‘a’ gets incremented and then gets assigned to the same variable. Whereas, ‘a++’ is called postfix increment. The value stored in the variable ‘a’ gets incremented after the execution of the particular line.


5 . What is a Dangling Pointer in C?

A pointer pointing to a dereferenced memory location is called dangling pointer. i.e. pointer pointing to the memory location which is deleted. There are three different ways where a pointer can act as a dangling pointer. De-allocation of memory When the local variable is not static When the variable goes out of scope


6 . Difference between malloc() and calloc() functions?

malloc and calloc are library functions that allocate memory dynamically, which means that memory is allocated during the runtime from the heap segment. Malloc and Calloc differ in the number of arguments used, their initialization methods and also in the return values.


7 . What is the difference between a structure and a Union?

All the members of a structure can be accessed simultaneously but union can access only one member at a time Altering the value of a member will not affect the other members of the structure but where it affects the members of a union Lesser memory is needed for a union variable than a structure variable of the same type


8 . What are static variables and functions?

The variables and functions that are declared using the keyword Static are considered as Static Variable and Static Functions. The variables declared using Static keyword will have their scope restricted to the function in which they are declared.


9 . Differentiate between Actual Parameters and Formal Parameters.

The Parameters which are sent from main function to the subdivided function are called as Actual Parameters and the parameters which are declared a the Subdivided function end are called as Formal Parameters.


10 . Can a C program be compiled or executed in the absence of a main()?

The program will be compiled but will not be executed. To execute any C program, main() is required.


Post Question Details