|
| 11 |
Difference between arrays and pointers? |
| Ans: |
Pointers are used to manipulate data using the address. Pointers use * operator to access the data pointed to by them.
Arrays use subscripted variables to access and manipulate data. Array variables can be
Equivalently written using pointer expression. |
|
|
| 12 |
Are pointers integers? |
| Ans: |
pointers are not integers. A pointer is an address. It is merely a positive number and not an integer. |
|
| 13 |
How are pointer variables? |
| Ans: |
Pointer variable are initialized by one of the following two ways
Static memory allocation
Dynamic memory allocation. |
|
| 14 |
What are the advantages of the pointer? |
| Ans: |
Debugging is easier
It is easier to understand the logic involved in the program
Testing is easier
Recursive call is possible
Irrelevant details in the user point of view are hidden in functions
Functions are helpful in generalizing the Program |
|
| 15 |
What is a pointer value and Address? |
| Ans: |
A pointer value is a data object that refers to a memory location. Each memory location is numbered in the memory. The number attached to a memory location is called the address of the location. |
|
| 16 |
What is a pointer variable? |
| Ans: |
A pointer variable is a variable that may contain the address of another variable or any valid address in the memory. |
|
| 17 |
What is static memory allocation and dynamic memory allocation? |
| Ans: |
Static memory allocation: The compiler allocates the required memory space for a declared variable. By using the address of operator, the reserved address is obtained and this address may be assigned to a pointer variable. Since most of the declared variable
Have static memory, this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.
Dynamic memory allocation: It 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 functions are assigned to pointer variables, such assignments are known as dynamic memory allocation. Memory is assigned during run time. |
|
| 18 |
What is the purpose of main ( ) |
| Ans: |
The function main ( ) invokes other functions within it. It is the first function to
Be called when the program starts execution.
It is the starting function
It returns an int value to the environment that called the program
Recursive call is allowed for main ( ) also.
It is a user-defined function
Program execution ends when the closing brace of the function main ( ) is reached.
It has two arguments 1) argument count and 2) argument vector (represents strings passed).
Any user-defined name can also be used as parameters for main ( ) instead of argc and argv |
|
| 19 |
What is the purpose of realloc ( )? |
| Ans: |
The function realloc (ptr, n) uses two arguments. the first argument ptr is a pointer to a block of memory for which the size is to be altered. The second argument n specifies the new size. The size may be increased or decreased. If n is greater than the old size and
If sufficient space is not available subsequent to the old region, the function realloc ( )
may create a new region and all the old data are moved to the new region. |
|
| 20 |
What are the advantages of auto variables? |
| Ans: |
1) The same auto variable name can be used in different blocks
2) There is no side effect by changing the values in the blocks
3) The memory is economically used
4) Auto variables have inherent protection because of local scope. |
|
| 21 |
Differentiate between an internal static and external static variable? |
| Ans: |
An internal static variable is declared inside a block with static storage class whereas an external static variable is declared outside all the blocks in a file. An internal static variable has persistent storage, block scope and no linkage. An external static variable has permanent storage, file scope and internal linkage. the function definition. They are preceded by their own data types. Actual arguments are available in the function call. |
|
| 22 |
What are advantages and disadvantages of external storage class? |
| Ans: |
Advantages of external storage class
1) Persistent storage of a variable retains the latest value
2) The value is globally available
Disadvantages of external storage class
1) The storage for an external variable exists even when the variable is not needed
2) The side effect may produce surprising output. |
|
| 23 |
What is storage class and what are storage variable? |
| Ans: |
A storage class is an attribute that changes the behavior of a variable. It controls
The lifetime, scope and linkage. There are five types of storage classes
1) Auto
2) Static
3) Extern
4) Register
5) Typed
|
|
| 24 |
What are the characteristics of arrays in C? |
| Ans: |
1) An array holds elements that have the same data type
2) Array elements are stored in subsequent memory locations
3) Two-dimensional array elements are stored row by row in subsequent memory locations.
4) Array name represents the address of the starting element
5) Array size should be mentioned in the declaration. Array size must be a constant expression and not a variable. |
|
| 25 |
Differentiate between a linker and linkage? |
| Ans: |
A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable |
|
| 26 |
What is a function and built-in function? |
| Ans: |
A large program is subdivided into a number of smaller programs or subprograms. Each subprogram specifies one or more actions to be performed for a large program. Such subprograms are functions. The function supports only static and extern storage classes. By default, function assumes extern storage class. functions have global scope. Only register or auto storage class is allowed in the function parameters. Built-in functions that predefined and supplied along with the compiler are known as built-in functions. They are also known as library functions. |
|