C PROGRAMMING INTERVIEW QUESTION ANSWER

C Language Picture


1) What is c language?


Ans: C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions.

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

3) What do you mean by the Scope of the variable? What is the scope of the variables in C?

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

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

5) Differentiate between calloc() and malloc()

Anscalloc() 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.

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

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

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

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

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

11) What is a C Token?

Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are referred to as C Tokens.

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

In case you are facing any challenges with these C Programming Interview Questions, please write your problems in the comment section below.

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

14) What is || operator and how does it function in a program?

Ans: The || is also known as the OR operator in C programming. When using || to evaluate logical conditions, any condition that evaluates to TRUE will render the entire condition statement as TRUE.

15) Can the “if” function be used in comparing strings?

Ans: No. “if” command can only be used to compare numerical values and single character values. For comparing string values, there is another function called strcmp that deals specifically with strings.

16) What are preprocessor directives?

Ans: Preprocessor directives are placed at the beginning of every C program. This is where library files are specified, which would depend on what functions are to be used in the program. Another use of preprocessor directives is the declaration of constants. Preprocessor directives begin with the # symbol.

17) What is wrong with this statement? myName = “Robin”;

Ans: You cannot use the = sign to assign values to a string variable. Instead, use the strcpy function. The correct statement would be: strcpy(myName, “Robin”);

18) How do you determine the length of a string value that was stored in a variable?

Ans: To get the length of a string value, use the function strlen(). For example, if you have a variable named FullName, you can get the length of the stored string value by using this statement: I = strlen(FullName); the variable I will now have the character length of the string value.

19) Is it possible to initialize a variable at the time it was declared?

Ans: Yes, you don’t have to write a separate assignment statement after the variable declaration, unless you plan to change it later on. For example: char planet[15] = “Earth”; does two things: it declares a string variable named planet, then initializes it with the value “Earth”.

20) What are reserved words?

Ans: Reserved words are words that are part of the standard C language library. This means that reserved words have special meaning and therefore cannot be used for purposes other than what it is originally intended for. Examples of reserved words are int, void, and return.

21) What are linked list?

Ans: A linked list is composed of nodes that are connected with another. In C programming, linked lists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage.

22) What is FIFO?

Ans: In C programming, there is a data structure known as queue. In this structure, data is stored and accessed using FIFO format, or First-In-First-Out. A queue represents a line wherein the first data that was stored will be the first one that is accessible as well.

23) What are binary trees?

Ans: Binary trees are actually an extension of the concept of linked lists. A binary tree has two pointers, a left one and a right one. Each side can further branch to form additional nodes, which each node having two pointers as well.

24) What information is given to the compiler while declaring a prototype function?

Ans: The following information is given while declaring a prototype function:

·               Name of the function

·               Parameters list of the function

·               Return type of the function.[6] 

25) Why are objects declared as volatile are omitted from optimization?

Ans: This is because, at any time, the values of the objects can be changed by code outside the scope of the current code. 

26) Give the equivalent FOR LOOP format of the following:

Ans: a=0;

while (a<=10) {

printf ("%d\n", a * a);

a++;

}

for (a=0; a<=10; a++)

printf ("%d\n", a * a);

27) What is a modifier in the C programming language? Name the five available modifiers.

Ans: It is used as a prefix to primary data type to indicate the storage space allocation’s modification to a variable. The available modifiers are: 

1.   short

2.   long

3.   long long

4.   signed

5.   unsigned

28) A pointer *a points to a variable v. What can ‘v’ contain?

Ans: Pointers is a concept available in C and C++. The variable ‘v’ might contain the address of another memory or a value.

 

Post a Comment

0 Comments