Pr.Pg Next Pg

C Programming Interview Questions and Answers Part 8


71.What are the pointer declarations used in C?

  • Array of pointers, e.g , int *a[10]; Array of pointers to integer

  • Pointers to an array,e.g , int (*a)[10]; Pointer to an array of into

  • Function returning a pointer,e.g, float *f( ) ; Function returning a pointer to float

  • Pointer to a pointer ,e.g, int **x; Pointer to apointer to int

  • pointer to a data type ,e.g, char *p; pointer to char


72.What is the invalid pointer arithmetic?

  • adding ,multiplying and dividing two pointers.

  • Shifting or masking pointer.

  • Addition of float or double to pointer

  • Assignment of a pointer of one type to a pointer of another type


73.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.


74.what is the difference between c &c++?

  • c++ ia an object oriented programing but c is a procedure oriented programing. c is super set of c++.

  • c can't suport inheritance,function overloading, method overloading etc. but c++ can do this.

  • In c-programe the main function could not return a value but in the c++ the main function shuld return a value.


75.What is multiple inheritance?

  • A class can inherit properties from more than one class which is known as multiple inheritance.


76.what is difference between function overloading and operator overloading?

  • A function is overloaded when same name is given to different function.

  • While overloading a function, the return type of the functions need to be the same.

  • Operator overloading is defining a function for a particular operator.

  • The operator loading function can not be overloaded through function overloading.


77.What are the advantages of inheritance?

  • Code reusability

  • Saves time in program development.


78.What is the difference between malloc and calloc?

  • malloc is use for memory allocation and initialize garbage values.malloc() for allocating the single block of memory, where as calloc is same as malloc but it initialize 0 value. calloc() for allocating multiple blocks of memory.


79.What is null pointer?

  • NULL pointer is a pointer which is pointing to nothing.

  • Examples :

int *ptr=(char *)0;

float *ptr=(float *)0;


80.How are pointer variables initialized?

  • Pointer variable are initialized in two ways :

  • Static memory allocation

  • Dynamic memory allocation

Pr.Pg border                                              Next Pg