C and C++ Interview Questions And Answers for freshers and experience

C and C++ interview questions and answers on advance and basic C and C++ with example so this page for both freshers and experienced condidate

from 31 to 45 C and C++ interview questions and answers

Question: 31 :: Where the memory to the Static variables is allocated?

Static Variables are allocated memory on the heap.

Question: 32 :: How Static variables and Local variablesare similar and dissimilar?

Similarity: Both Static varables and Local variables are similar in terms of their scope, i.e, both of them are local to the block of code in which they are created.
Dissimilarity: Both of them are dissimilar in terms of their lifespan,i.e, static variablea have lifespan throughout the program whereas the lifespan of the local variables is local to block of code in which they are created.


Question: 33 :: Eplain Extern keyword?

Extern keyword is used when there is a requirement of making variables global and accessible across the files. This keyword signifies the presence of the variable or the funtion to the compiler.
It is used only for the declaration of the variables or the functions not for their definition.
Variables prefixed with this keyword should not be initialised. Important thing to note is that the extern declaration does not create any storage.

Question: 34 :: What do you mean by funtion Prototype?

Funtion Prototype are generally declarations placed in the header files. It tells the compiler the function like the name of the function, its type ,i.e, what types of inputs the function will receive and what type of output it will return to the calling function.

Question: 35 :: Can a function take variable length arguments, If yes, how?

Yes,the function can take variable length arguments with the help of ellipses.
Ellipses in the function indicates that the function may receive variable length arguments.
Example: printf function can take variable length arguments. It is declared as:
extern int printf(const char *, ...)
In the above declaration '...'(three dots) indicates the presence of ellipses showing that the function may receive variable length arguments.

Question: 36 :: What do you mean by function pointer?

Function pointer are the pointers that points to the address of a function. Each function in C is addressed in code segment. This address of the of the function is stored in a pointer. This function is invoked from this pointer whenever required as it holds the address of the function in the code segment.

Question: 37 :: What is Lvalue?

Lvalues are the expressions that refer to memory locations. lvalues appear on the left of the '=' sign. The name of the identifier indicates the storage location while the value indicates the value stored at the location. Example x=15; in this 'x' is the Lvalue.

Question: 38 :: What is Rvalue?

Rvalues describes the value of the expression to be assigned to the Lvalue. It appears on the right side of the '=' sign , i.e , Rvalue is the data value to the variable to be assigned to Lvalue.
Exanple x= 15; In this 15 is the Rvalue.

Question: 39 :: What is the use of function pointer?

Function pointer are used to call a function defined at the run-time. It is a variable that stored the address of a function that can later be called through function pointer. These are also used to implement function pointers.

Question: 40 :: What is the use of volatile variable?

volatile keyword is used to prevent the code from optimization by compiler. This keyword tells the compiler that value of the variable may change so ot prevents from being optimized. It is generally used on objects that are shared between threads or programs.

Question: 41 :: What is the difference between *p++ and (*p)++ ?

In *p++, since ++ is associated from right to left *p++ increments p but returns the value pointed by the p before increments whereas (*p)++ increments the value pointed to by p.

Question: 42 :: How to declare an array of pointers to integer?

int *a[20]; where 'a' is an array of pointersto integers.

Question: 43 :: How to declare a pointer to an array of integers?

int (*a)[20]; where 'a' is a pointer to array of integers.

Question: 44 :: What size is allocated to the union variable?

Size allocated to the variables of the inion is the maximum size, i.e , the size of its biggest variables. When sizeof is applied on a unions it gives the size of its biggest variable/member.

Question: 45 :: what is the output of 3["OUTPUT"]?

p, is the output of the the given snippet.
The expressiom 3["OUTPUT"] is equivalent to "OUTPUT"[3]
Expression a[b], *(a+b), *(b+a) and b[a] are equivalent.

Go On Top

Next PageNext Page



Ask your interview questions on C and C++

Write Your comment or Questions if you want the answers on C and C++ from C and C++ Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---