C Programming Interview Questions

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

Ans. 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.

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

Ans. 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.

Ques 3. What is Memory Leak in C?

Ans. 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.

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

Ans. ‘++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.

Ques 5. What is a Dangling Pointer in C?

Ans. 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

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

Ans. 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.

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

Ans. 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

Ques 8. What are static variables and functions?

Ans. 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.

Ques 9. Differentiate between Actual Parameters and Formal Parameters.

Ans. 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.

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

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

Post Question Details


Posted On:12/20/2022 9:28:02 AM

Ques. What is c?

Posted On:8/12/2020 4:54:45 PM

Ques. Test

Posted On:5/2/2020 7:49:19 PM

Ques. gghh

Posted On:3/4/2020 11:19:46 PM