C++ Programs Asked in Interview for Freshers - 3

Question: 11

What is Call by value method in functions?

In this method, the called function creates new variables to store the value of the arguments passed to it.

This method copies the values of actual parameters (parameters associated with call statement) into the formal parameters (the parameters associated with function header), thus the function creates its own copy of arguments and then uses them.

Question: 12

What is Call by reference method in function?

The called function arguments – formal parameters become alias to the actual parameters in the calling function.

This means that when the function is working with its own arguments, it is actually working on the original data.

Question: 13

What is the main purpose of using function prototype?

The main purpose of function prototype is to help the compiler to check the data requirement of the function. With function prototyping, a template is always used when declaring and defining a function.

When a function is called, the compiler uses the template to ensure that proper arguments are passed, and the return value is treated correctly.

Any violation in matching of the arguments or the return types will be treated as errors by compiler, and flagged at the time of compilation.

Question: 14

What is function overloading?

The ability of the function to process the message or data in more than one form is called as function overloading.

Related Questions