Interview Questions
There are the collection of some most important questions which been asked during an interview, so we decided to also share these with you. Hope you will like these if you have any query them feel free to contact us. We will be happy to know.
Interview Questions related to c, c++ and oops.
Q31. What is the purpose of realloc()?
Realloc(ptr,n) function 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.
Q32. What is a pointer value and address?
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.
Q33. What is the use of typedef?
The typedef help in easier modification when the programs are ported to another machine.A descriptive new name given to the existing data type may be easier to understand the code.
Q34. What are the differences between new and malloc?
New initializes the allocated memory by calling the constructor. Memory allocated with new should be released with delete.
Malloc allocates uninitialized memory.
The allocated memory has to be released with free.new automatically calls the constructor while malloc(dosen't)
Q35. What is the difference between strdup and strcpy?
Both copy a string. strcpy wants a buffer to copy into. strdup allocates a buffer using malloc(). Unlike strcpy(), strdup() is not specified by ANSI.
Q36. What is friend function?
The function declaration should be preceded by the keyword friend.The function definitions does not use either the keyword or the scope operator ::. The functions that are declared with the keyword friend as friend function.Thus, a friend function is an ordinary function or a member of another class.
Q37. What is recursion?
A recursion function is one which calls itself either directly or indirectly it must halt at a definite point to avoid infinite recursion.
Q38. What are the characteristics of arrays in C?
are the characteristics of arrays in C are as follows:
1. An array holds elements that have the same data type.
2. Array elements are stored in subsequent memory locations Two-dimensional.
3. Array elements are stored row by row in subsequent memory locations.
4. Array name represents the address of the starting element.
Q39. What is the differentiate between for loop and a while loop? What are it uses?
For executing a set of statements fixed number of times we use for loop while when the number of iterations to be performed is not known in advance we use while loop.
Q40. What is the difference between printf(...) and sprintf(...)?
printf(....) -------------> is standard output statement sprintf(......)-----------> is formatted output statement.
Q41. What is an explicit constructor?
A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction.Explicit constructors are simply constructors that cannot take part in an implicit conversion.
Q42. 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.
Q43. 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.
Q44. What is multiple inheritance?
A class can inherit properties from more than one class which is known as multiple inheritance.
Q45. what is difference between function overloading and operator Overloading?
Function OverloadingA 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 OverloadingA operator is overloaded when same operator name is given to different function. for example '+' operator usually used for adding two integers but we can also use '+' as symbol in string for example "Hello + world".