2-It initializes the contains of block of memory to zerosMalloc takes one argument, memory
allocated contains garbage values.
It allocates contiguous memory locations. Calloc takes two arguments, memory allocated
contains all zeros, and the memory allocated is not contiguous.
10. What are macros? What are its advantages and disadvantages?
Ans: Macros are abbreviations for lengthy and frequently used statements. When a macro is
called the entire code is substituted by a single line though the macro definition is of several
lines.
The advantage of macro is that it reduces the time taken for control transfer as in case of
function. The disadvantage of it is here the entire code is substituted so the program becomes
lengthy if a macro is called several times.
Read more: c interview questions for freshers | FreeJobAlert.com
http://www.freejobalert.com/clanguage-
interview-questions-part1/6125/#ixzz1O1xitnOp
11. Difference between pass by reference and pass by value?
Ans: 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.)
12. What is static identifier?
Ans: A file-scope variable that is declared static is visible only to functions within that file. A
function-scope or block-scope variable that is declared as static is visible only within that scope.
Furthermore, static variables only have a single instance. In the case of function- or block-scope
variables, this means that the variable is not ―automatic‖ and thus retains its value across
function invocations.
13. Where is the auto variables stored?
Ans: Auto variables can be stored anywhere, so long as recursion works. Practically, they‘re
stored on
the stack. It is not necessary that always a stack exist. You could theoretically allocate function
invocation records from the heap.
14. Where does global, static, and local, register variables, free memory and C Program
instructions get stored?
Ans: Global: Wherever the linker puts them. Typically the ―BSS segment‖ on many platforms.
Static: Again, wherever the linker puts them. Often, they‘re intermixed with the globals. The
only difference between globals and statics is whether the linker will resolve the symbols across
compilation units.Local: Typically on the stack, unless the variable gets register allocated and
never spills.Register: Nowadays, these are equivalent to ―Local‖ variables. They live on the stack
unless they get register-allocated.
15. Difference between arrays and linked list?
Ans: An array is a repeated pattern of variables in contiguous storage. A linked list is a set of
structures scattered through memory, held together by pointers in each element that point to the
next element. With an array, we can (on most architectures) move from one element to the next
by adding a fixed constant to the integer value of the pointer. With a linked list, there is a ―next‖
pointer in each structure which says what element comes next.
16. What are enumerations?
Ans: They are a list of named integer-valued constants. Example:enum color { black , orange=4,
www.cpp-progams.blogspot.com