C Language Interview Question and Answers
Categories: C Programming language C language
C Language Interview Question and Answers
Q 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.
Q 2: What do you mean by the Scope of the variable? What is the scope of the variables in C?
Ans: Scope of the variable can be defined as the part of the code area where the variables declared in the program can be accessed directly. In C, all identifiers are lexically (or statically) scoped.
Q 3: 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.
Q 4: 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.
Q 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
Q 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.
Q 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.
Q 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.
Q9: What is a C Token?
Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are referred to as C Tokens.
Q 10: What is Preprocessor?
Ans: A Preprocessor Directive is considered as a built-in predefined function or macro that acts as a directive to the compiler and it gets executed before the actual C Program is executed.
Q 11: Why is C called the Mother of all Languages?
Ans: C introduced many core concepts and data structures like arrays, lists, functions, strings, etc. Many languages designed after C are designed on the basis of C Language. Hence, it is considered as the mother of all languages.