Library function
|
User defined function
|
a. It is a predefined function in a header file or preprocessor directive.
b. Programmer can simply use this function by including respective header files.
c. The program using library function will be usually short as the programmer doesn’t have to define the function.
d. Program development time will be faster.
e. Example. Printf( ), getch( ), strlen( )
|
a. User defined function is not a predefined function. It is defined by the programmer according to the need.
b. Programmer has to declare, define and use this function by them.
c. The program using user defined function will be usually lengthy as the programmer has to define the function.
d. Program development time will be usually slower.
e. Example: Sum( ), area( ), Factorial( ), etc.
|
Differences between array and structure
ARRAY
|
STRUCTURE
|
An array is a collection of variables of same data type.
|
A structure is a collection of variables of different data type.
|
type array_name[size];
|
struct sruct_name{
type element1; type element1; . . } variable1, variable2, . .; |
Array elements are stored in contiguous memory location.
|
Structure elements may not be stored in a contiguous memory location.
|
Array elements are accessed by their index number.
|
Structure elements are accessed by their names.
|
Array declaration and element accessing operator is "[ ]" (square bracket).
|
Structure element accessing operator is "." (Dot operator).
|
Array name points to the first element in that array so, array name is a pointer.
|
Structure name does not point to the first element in that structure so, structure name is not a pointer.
|
Objects (instances) of an array can not be created.
|
Structure objects (instance or structure variable) can be created.
|
Every element in array is of same size.
|
Every element in a structure is of different data type.
|
Bit filed can not be defined in an array.
|
Bit field can be defined in a structure.
|
There is no keyword to declare an array.
|
"struct" is a keyword used to declare the structure.
|
Arrays are not user-defined they are directly declared.
|
Structure is a user-defined datatype.
|