Posts

Showing posts with the label C Programming Language Interview Question

Difference between formal argument and actual argument?

Difference between formal argument and actual argument? Formal arguments are the arguments available in the function definition. They are preceded by their own data type. Actual arguments are available in the function call. These arguments are given as constants or variables or expressions to pass the values to the function.

What are built in functions?

What are built in functions? The functions that are predefined and supplied along with the compiler are known as builtin functions. They are also known as library functions. 

What is an argument?

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

What is a function?

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.

What modular programming?

What modular programming? If a program is large, it is subdivided into a number of smaller programs that are called modules or subprograms. If a complex problem is solved using more modules, this approach is known as modular programming.

Why is it necessary to give the size of an array in an array declaration?

Why is it necessary to give the size of an array in an array declaration? When an array is declared, the compiler allocates a base address and reserves enough space in memory for all the elements of the array. The size is required to allocate the required space and hence size must be mentioned. 

Is it possible to have negative index in an array?

 Is it possible to have negative index in an array?  Yes it is possible to index with negative value provided there are data stored in this location. Even if it is illegal to refer to the elements that are out of array bounds, the compiler will not produce error because C has no check on the bounds of an array. 

Difference between linker and linkage?

Difference between linker and linkage? Linker converts an object code into an executable code by linking together the necessary built in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable

What is an array of pointers?

What is an array of pointers?  if the elements of an array are addresses, such an array is called an array of pointers. 

What is pointer to a pointer?

What is pointer to a pointer?  If a pointer variable points another pointer value. Such a situation is known as a pointer to a pointer. Example:  int *p1,**p2,v=10;  P1=&v; p2=&p1;  Here p2 is a pointer to a pointer.

What is the purpose of realloc?

What is the purpose of realloc? It increases or decreases the size of dynamically allocated array. 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 specifies the new size. The size may be increased or decreased. If sufficient space is not available to the old region the function may create a new region

What is dynamic memory allocation?

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. 

What is static memory allocation?

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.

How pointer variables are initialized?

How pointer variables are initialized?  Pointer variables are initialized by one of the following ways.  I. Static memory allocation  II. Dynamic memory allocation

What is generic pointer in C?

What is generic pointer in C? In C void* acts as a generic pointer. When other pointer types are assigned to generic pointer, conversions are applied automatically (implicit conversion). 

What does the error ‘Null Pointer Assignment’ means and what causes this error?

What does the error ‘Null Pointer Assignment’ means and what causes this error? As null pointer points to nothing so accessing a uninitialized pointer or invalid location may cause an error.

Are pointers integer?

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

What is a NULL Pointer? Whether it is same as an uninitialized pointer?

 What is a NULL Pointer? Whether it is same as an uninitialized pointer? Null pointer is a pointer which points to nothing but uninitialized pointer may point to anywhere.

In C, why is the void pointer useful? When would you use it?

In C, why is the void pointer useful? When would you use it? The void pointer is useful because it is a generic pointer that any pointer can be cast into and back again without loss of information.

What is near pointer?

What is near pointer? A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the data/code to 64kb segment.