Loading...

C Programming Interview Questions

This article is mainly focused on the most repeatedly asked and the latest updated questions.

C Interview Questions Set-2

Commonly Asked C Programming Interview Questions | Set 2


1. What do you mean by Dangling Pointer Variable in C Programming?
Ans: A Pointer in C Programming is used to point the memory location of an existing variable. In case if that particular variable is deleted and the Pointer is still pointing to the same memory location, then that particular pointer variable is called as a Dangling Pointer Variable.


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


3. Differentiate between calloc() and malloc()?
Ans: calloc() and malloc() are memory dynamic memory allocating functions. The only difference between them is that calloc() will load all the assigned memory locations with value 0 but malloc() will not.


4. What are the valid places where the programmer can apply Break Control Statement?
Ans: Break Control statement is valid to be used inside a loop and Switch control statements.


5. How can we store a negative integer?
Ans: To store a negative integer, we need to follow the following steps. Calculate the two’s complement of the same positive integer.

Eg: 1011 (-5)
Step-1 − One’s complement of 5: 1010.
Step-2 − Add 1 to above, giving 1011, which is -5.


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


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


8. What do you mean by a Nested Structure?
Ans: When a data member of one structure is referred by the data member of another function, then the structure is called a Nested Structure.


9. What is the purpose of printf() and scanf() in C Program?
Ans: printf() is used to print the values on the screen. To print certain values, and on the other hand, scanf() is used to scan the values. We need an appropriate datatype format specifier for both printing and scanning purposes. For example,

  • %d: It is a datatype format specifier used to print and scan an integer value.
  • %s: It is a datatype format specifier used to print and scan a string.
  • %c: It is a datatype format specifier used to display and scan a character value.
  • %f: It is a datatype format specifier used to display and scan a float value.


10. What is Preprocessor?
Ans: Preprocessor is a macro processor which is automatically used by the compiler to transform the program before its actual compilation.


- Related Topics