Wednesday, December 4, 2013

Nitheen Kumar

C Language Interview Questions 7

91. What are library Functions?
Library Functions are predefined functions and stored in .lib files.

92. What is a structure?
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.

93. What is a pointer?
Pointer is a variable that contains address of another variable in the memory. Pointers are quite useful in creation of linked data structures (such as linked lst, trees graphs), managing object allocated memory dynamically, optimize the program to execute faster and use less memory.

94. What are the techniques you use for debugging?
(i)Using compiler’s features
(ii)Read The Fine Module
(iii)printf( ) debugging
(iv)Code grinding
(v)Assertion

95. What are macros? What are its advantages and disadvantages?
Macro is a Pre-processor.Major advantage of using the macro is to increase the speed of the execution of the program.
Major disadvantage of the macros are:
(i) No type checking is performed in macro. This may cause error.
(ii)  A macro call may cause unexpected results.

96. What is difference between Structure and Unions?
(i)    In structure every member has its own memory whereas in union its members share the same member space.
(ii)  In structure, it is possible to initialize all the members at the same time which is not possible in case of union.
(iii) A structure requires more space than union(for the same type of members).
(iv) In union different interpretations of the same memory space are possible which is not so in case of structures.

97. What are the advantages of using Unions?
(i) Efficient use of memory as it it does not demand memory space for its all members rather it require memory space for its largest member only.
(ii) Same memory space can be interpreted differently for different members of the union.

98. What is the difference between ordinary variable and pointer in C?
An ordinary variable is like a container it can hold any value and we can change the value of ordinary variable at a time throughout the program .A pointer is a variable that stores the address of another Variable.

99. What are segment and offset addresses?

When paging technique is performed, the page will breaks into segments and its sequence is said to be segments and its width can be said as offset. In short,segment is a physical address and offset is logical address.

100. When should a type cast be used?
There are two situations in which to use a type cast. The first use is to change the type of an operand to an arithmetic operation so that the operation will be performed properly.
The second case is to cast pointer types to and from void * in order to interface with functions that expect or return void pointers. For example, the following line type casts the return value of the call to malloc() to be a pointer to a foo structure.
struct foo *p = (struct foo *) malloc(sizeof(struct foo));

101. What is the difference between %d and %*d in c language?
%d give the original value of the variable and %*d give the address of the variable.
eg:-int a=10,b=20;
printf("%d%d",a,b);
printf("%*d%*d",a,b);
Result is 10 20 1775 1775 .Here 1775 is the starting address of the memory allocation for the integer.a and b having same address because of contagious memory allocation.

102. How does a C program come to know about command line arguments?

 When we execute our C program, operating system loads the program into memory. In case of DOS, it first loads 256 bytes into memory, called program segment prefix. This contains file tables,environment segment, and command line information. When we compile the C program the compiler inserts additional code that parses the command, assigning it to the argv array, making the arguments easily accessible within our C program.

103. How are pointer variables initialized?
 Pointer variable are initialized by one of the following two ways
- Static memory allocation
- Dynamic memory allocation

104. What is modular programming?
If a program is large, it is subdivided into a number of smaller
programs that are called modules or subprograms. If a complex
problem is solved using more modules, this approach is known as
modular programming

105. Where does global, static, local, register variables and C Program instructions get stored?
Global , static, local :  In main memory  
Register variable: In registers
C program : In main memory.

Prv 1 2 3 4 5 6 7 8 9 10 11 Next

Subscribe to get more Posts :