Fri Jul 13 2018

C programming language related interview questions

Tips and Tricks837 views

C interview questions

C programming language was developed in between 1969 and 1973 by Dennis Ritchie at Bell Labs. He uses this new programming language for re-implement UNIX operating system. C is a high-level structured oriented programming language use to general purpose programming requirements. Basically, C is a collection of its library functions. It is also flexible to add user-defined functions and includes those in C library. The main usage of C programming language is  Language Compilers, Operating Systems, Assemblers, Text Editors, Print Spoolers, Network Drivers, Modern Programs, Data Bases, Language Interpreters, and Utilities. Many companies are searching for good C programmers and ready to higher pays for the right candidates. They are taking interviews to hire programmers. To make those interviews easy for you, here we are going to highlight some essential C interview questions that you may encounter during your interviews for the subject of C Programming.

So, check out the questions -

Q. What is C language?

Ans. C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope, and recursion, while a static type system prevents many unintended operations. This language provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, including operating systems, as well as various application software for computers ranging from supercomputers to embedded systems.

Q. Why C called as a mother language?

Ans. C is also called mother Language of all programming Language because it supports some features of low-level programming language and basic of all high-level programming language.

Q. Why use C language?

Ans. C language is used to develop system software and Operating System.

Q. What are the main characteristics of C language?

And. C is a procedural language. The main features of C language include low-level access to memory, the simple set of keywords, and clean style. These features make it suitable for system programmings like the operating system or compiler development.

Q. What is the difference between Call by Value and Call by Reference?

Ans. When using Call by Value, you are sending the value of a variable as the parameter to a function, whereas Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.

Q. What is the description for syntax errors?

Ans. The mistakes when creating a program called syntax errors. Misspelled commands or incorrect case commands, an incorrect number of parameters when called a method /function, data type mismatches can identify as common examples for syntax errors.

Q. What is a scope of a variable? How are variables scoped in C?

Ans. The scope of a variable is the part of the program where the variable may directly be accessible. In C, all identifiers are lexically or statically scoped.

Q. What is a NULL pointer?

Ans. NULL is used to indicate that the pointer doesn’t point to a valid location. Ideally, we should initialize pointers as NULL if we don’t know their value at the time of declaration. Also, we should make a pointer NULL when memory pointed by it is deallocated in the middle of a program.

Q. What is Dangling pointer?

Ans. Dangling Pointer is a pointer that doesn’t point to a valid memory location. Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory.

Q. What is a memory leak? Why should it be avoided?

Ans. The memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs like daemons and servers which by definition never terminate.

Q. What are static functions? What is their use?

Ans. In C, functions are global by default. The “static” keyword before a function name makes it static. Unlike global functions in C, access to static functions is restricted to the file where they are declared. Therefore, when we want to restrict access to functions, we make them static. Another reason for making functions static can be reuse of the same function name in other files.

Q. What is a volatile keyword?

Ans. The volatile keyword is intended to prevent the compiler from applying any optimizations on objects that can change in ways that cannot be determined by the compiler. Objects declared as volatile are omitted from optimization because their values can be changed by code outside the scope of current code at any time.

Q. Why C is called a mid-level programming language?

Ans. It supports the feature of both low-level and high-level languages that is why it is known as a mid-level programming language.

Q. What is the use of printf() and scanf() functions?

Ans. The printf() function is used for output and scanf() function is used for input.

Q. What is the use of the static variable in C?

Ans. A variable which is declared as static is known as the static variable. The static variable retains its value between multiple function calls.

Q. What is recursion in C?

Ans. Calling the same function, inside the function is known as recursion.

Q. What is an array in C?

Ans. An array is a group of similar types of elements. It has a contiguous memory location. It makes the code optimized, easy to traverse and easy to sort.

Q.What is a pointer in C?

Ans. A pointer is a variable that refers to the address of a value. It makes the code optimized and makes the performance fast.

Q. What is the meaning of base address of the array?

Ans. The starting address of the array is called the base address of the array.

Q. When should we use the register storage specifier?

Ans. If a variable is used most frequently then it should be declared using register storage specifier, then possibly the compiler gives CPU register for its storage to speed up the lookup of the variable.

Q. What is a nested structure?

Ans. A structure containing an element of another structure as its member is referred so.

Q. What is lvalue and rvalue?

Ans. The expression appearing on the right side of the assignment operator is called as rvalue. Rvalue is assigned to lvalue, which appears on the left side of the assignment operator. The lvalue should designate to a variable not a constant.

Q. What is the advantage of declaring void pointers?

Ans. When we do not know what type of the memory address the pointer variable is going to hold, then we declare a void pointer for such.

Q. Can a program be compiled without main() function?

Ans. Yes, it can be but cannot be executed, as the execution requires main() function definition.

Q. What are bit fields?

Ans. We can create integer structure members of differing size apart from non-standard size using bit fields. Such structure size is automatically adjusted with the multiple of integer size of the machine.

Q. Where an automatic variable is stored?

Ans. Every local variable by default being an auto variable is stored in stack memory.

Q. Does a built-in header file contains built-in function definition?

Ans. No, the header file only declares the function. The definition is in the library which is linked by the linker.

Q. What is a token?

Ans. A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

Q. How does bitwise operator XOR work.

Ans. If both the corresponding bits are same it gives 0 else 1.

Q. How many operators are there under the category of ternary operators?

Ans. There is only one operator and is a conditional operator (? : ).

Q. What is the full form of ANSI?

Ans. American National Standards Institute.

Q. Can we assign a float variable to a long integer variable?

Ans. Yes, with loss of a fractional part.

Q. Can a pointer access the array?

Ans. Pointer by holding array base address can access the array.

Q. What is typecasting?

Ans. Typecasting is a way to convert a variable/constant from one type to another type.

Q. What is recursion?

Ans. Function calling itself is called as recursion.

Q. What is the maximum length of an identifier?

Ans. Ideally, it is 32 characters and also implementation dependent.

Q. What is a constant pointer?

Ans. A pointer which is not allowed to be altered to hold another address after it is holding one.

Q. What is a constant?

Ans. A value which cannot be modified is called so. Such variables are qualified with the keyword const.

Q. What is the difference between far and near pointers?

Ans. In the first place, they are non-standard keywords. A near pointer can access only 2^15 memory space and the far pointer can access 2^32 memory space. Both the keywords are implementation specific and are non-standard.

Q. What are macros?

Ans. Macros is a small fragment of code that is assigned with a name. Wherever that name is used it is replaced by the code in macros.

Q. What is Garbage value?

Ans. Garbage value can be any value given by system and that is no way related to correct programs. It is a disadvantage and it can overcome using variable initialization. In C programming avoid garbage collection by using variable initialization.

What is the data type?

Ans. The data type is a keyword used to identify the type of data. Data types are used for representing the input of the user in the main memory (RAM) of the computer.

Q. What is a buffer in C

Ans. The temporary storage area is called a buffer.

Q.  Difference between arrays and linked list?

Ans. Major differences between arrays and linked lists are: (i) In array consecutive elements are stored in consecutive memory locations whereas in the linked list is not so. (ii) In array address of next element is consecutive and whereas in the linked list it is specified in the address part of each node. (iii) Linked List makes better use of memory than arrays. (iv) Insertion or deletion of an element in the array is difficult than insertion or deletion in the linked list.



 

Lastly say, the questions that we mentioned above are not only you will be asked in the interviews. There is a huge list of questions available related to C that interviewer may ask. It only depends on them. Hope this article successfully guided you and helped you to understand the level of interview questions. Best of luck for the future! Thank you!

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.