Argument Passing Mechanism Important Questions

Jan 11 • Resources • 2976 Views • 4 Comments on Argument Passing Mechanism Important Questions

Q1. What do you mean by argument passing mechanism?
Ans- The exact mechanism for assigning arguments to parameters, called argument passing, depends upon the evaluation strategy used for that parameter (typically call-by-value), which may be specified using keywords. When we pass a value either by value or by reference in Visual Basic, then it is known as the Passing Parameter. The Passing Mechanism is related to different programming languages like C and Visual basic. There are different ways of passing argument which are stated as follows-

Argument Passing Mechanism

Argument/ Parameter Passing Mechanism

Q2. What is an Argument in c programming?
Ans- Arguments are more properly thought of as the actual values or references assigned to the parameter variables when the subroutine is called at runtime. Arguments are the type of variables that can be used by the functions in C language. An Argument is similar to a parameter and is something that has been passed to a function.

For Example-
int main(int argc, char **argv);
“argc” and “argv” are the arguments which are being passed into the main function.

Q3. What do you mean by call by value and call by reference argument passing mechanism?
Ans- When passing data by value, the data is copied to a local variable/object in the function. Changes to this data are not reflected in the data of the calling function. For larger objects, passing data by value can be very expensive.
When passing data by reference, a pointer to the data is copied instead. Changes to the data pointed to by the pointer are reflected in the data of the calling function. Regardless of the size of the object, passing data by reference always has the same cost.

Q4. What is the advantage of call by reference argument passing mechanism over call by value?
Ans- It uses pointers, so there is no doubling of the memory used by the variables. This lowers the memory footprint.

Element typePassed ByValPassed ByRef
Value type (contains only a value)This procedure will not change the variable or any of its members.This procedure will change the variable and its members.
Reference type (contains a pointer to a class or structure instance)The procedure cannot change the variable but can change members of the instance to which it points.The procedure can change the variable and members of the instance to which it points.

Q5.  When we are most expected to use call by reference argument passing mechanism?
Ans- If frequent data changes are expected.

Q6. What are the disadvantages of using call by reference argument passing mechanism?
Ans- Unwanted side effects and less privacy of data.

Q7. Give syntax of call by reference argument passing mechanism?
Ans- <Type> & <Name>
where <Type> is a type and <Name> is an identifier whose type is reference to <Type>

for example: int A=5;
int& rA=A;

State TRUE or FALSE-

Q8. When argument passing mechanism is”by value”, the function works with the original arguments in the calling program. Is this true?
Ans- True

Q9. A function can return a value by reference. Is statement true or false?
Ans- True

Q10. When a function returns a value, the entire function call can be assigned to a variable. True or False?
Ans- True

So these are the some of the important questions and answers on Parameter Passing Mechanism. Download the questions in pdf from here IMPORTANT QUESTIONS ON PARAMETER PASSING MECHANISM.pdf

Give your suggestions and views in the comments section below this article to make it more perfect and useful for you.

Related Links-
Sample Paper for C programming
Questions on inheritance in C++ with Answers
Important SQL questions and answers with practice questions

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

4 Responses to Argument Passing Mechanism Important Questions

  1. Ritika says:

    For all those who want to be fully prepared for the interviews!

  2. sakshi chaudhary says:

    this post contain all the necessary details which give a the detailed knowledge about the argument passing mechanism…!!!!

  3. saurabh singh says:

    This article provides us with detailed insight about the questions of “argument passing mechanism”.

  4. Siddhant Tripathi says:

    FAQs on Argument passing procedure and syntax in C.

« »