C Programming theory Questions and answers – Part 2

51. What is dynamic memory allocation?
Answer : 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.

52. What is a function?
Answer : 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.

53. What is an argument?
Answer : An argument is an entity used to pass data from the calling to a called function.

54. what is the similarity between a Structure, Union and enumeration?
Answer : All of them let the programmer to define new data type.

55. Difference between array and pointer?
Answer : Array
a – Array allocates space automatically
b – It cannot be resized
c – It cannot be reassigned
d – sizeof (arrayname) gives the number of bytes occupied by the array.
Pointer
a – Explicitly assigned to point to an allocated space.
b – It can be sized using realloc()
c – pointer can be reassigned.
d – sizeof (p) returns the number of bytes used to store the pointer variable p.

COPY CODE SNIPPET