Interview Questions C

C


151. Differentiate between a for loop and a while loop? What are it uses?
For executing a set of statements fixed number of times we use for loop while when the number of
iterations to be performed is not known in advance we use while loop.

152. What is storage class? What are the different storage classes in C?
: Storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. The storage classes in c are auto, register, and extern, static, typedef.

153. Difference between pass by reference and pass by value?
Pass by reference passes a pointer to the value. This allows the callee to modify the variable directly.Pass by value gives a copy of the value to the callee. This allows the callee to modify the value without modifying the variable. (In other words, the callee simply cannot modify the variable, since it lacks a reference to it.)

154. What are enumerations?
They are a list of named integer-valued constants. Example:enum color { black , orange=4,yellow, green, blue, violet };This declaration defines the symbols "black", "orange", "yellow", etc. to have the values "1," "4," "5," ... etc. The difference between an enumeration and a macro is that the enum actually declares a type, and therefore can be type checked.

155. Are pointers integer?
No, pointers are not integers. A pointer is an address. It is a positive number.

156. What is static memory allocation?
Compiler allocates memory space for a declared variable. By using the address of operator, the reserved address is obtained and this address is assigned to a pointer variable. This way of assigning pointer value to a pointer variable at compilation time is known as static memory allocation.

157. What is dynamic memory allocation?
A dynamic memory allocation uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these function are assigned to pointer variables, such a way of allocating memory at run time is known as dynamic memory allocation.

158. What is a function?
A large program is subdivided into a number of smaller programs or subprograms. Each subprogram specifies one or more actions to be performed for the larger program. Such sub programs are called functions

159. what are C tokens?
There are six classes of tokens: identifier, keywords, constants, string literals, operators and other separators.

160. What are C identifiers?
These are names given to various programming element such as variables, function, arrays.It is a combination of letter, digit and underscore.It should begin with letter. Backspace is not allowed