Interview Questions C


1. Why C Language is used?
C is one of the high level languages. It is a general purpose language, which means it can be used to write programs of any sort.

2. What are the features of C Languages?
1. In C one can write programs like that of high level languages as in COBOL, BASIC, FORTRAN etc. as well as it permits very close interaction with the inner workings of the computer. 
2. It is a general purpose programming language. It is usually called system programming language but equally suited to writing a variety of applications.
3.It supports various data types
4. It follows the programming style based on fundamental control flow constructions for structured programming
5. Functions may be pre?defined or user defined and they may return values of basic types, structures, unions or pointers.

3. What are the advantages of C language?
1. Easy to write 
2. Rich set of operators and functions that are built?in
3. Support for bit?wise operation
4. Flexible use of pointers
5. Direct control over the hardware
6. Ability to access BIOS/DOS routines
7. Interacting using Interrupts
8. Ability to write TSR programs
9. Ability to create .COM files
10. Ability to create library files (.LIB)
11. Ability to write interface programs
12. Incorporating assembly language in C program

4. What does static variable mean?
Static variables are the variables which retain their values between the function calls. They are initialized only once their scope is within the function in which they are defined.

5. What is a pointer?
Pointers are variables which stores the address of another variable. That variable may be a scalar (including another pointer), or an aggregate (array or structure). The pointed-to object may be part of a larger object, such as a field of a structure or an element in an array.

6. What are the uses of a pointer?
Pointer is used in the following cases
1. It is used to access array elements
2. It is used for dynamic memory allocation.
3. It is used in Call by reference
4. It is used in data structures like trees, graph, linked list etc.

7. What is a structure?
Structure constitutes a super data type which represents several different data types in a single unit. A structure can be initialized if it is static or global. Or Structure is a collection of heterogeneous (i.e. related data items which can be of different types) held together to a single unit. The data items enclosed within a structure are called its members which may be of data type int, float, char, array etc.

8. What is a union?
Union is a collection of heterogeneous data type but it uses efficient memory utilization technique by allocating enough memory to hold the largest member. Here a single area of memory contains values of different types at different time. A union can never be initialized.

9. What are the differences between structures and union?
A structure variable contains each of the named members, and its size is large enough to hold all the members. Structure elements are of same size.
A union contains one of the namedmembers at a given time and is large enough to hold the largest member. Union element can be of different sizes.

10. What are the differences between structures and arrays?
Structure is a collection of heterogeneous data type but array is a collection of homogeneous data types.
1-It is a collection of data items of same data type.
2-It has declaration only
3-.There is no keyword.
4- array name represent the address of the starting element.
1-It is a collection of data items of different data type.
2- It has declaration and definition
3- keyword struct is used
4-Structure name is known as tag it is the short hand notation of the declaration.