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-
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.
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 type||Passed ByVal||Passed 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;
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?
Q9. A function can return a value by reference. Is statement true or false?
Q10. When a function returns a value, the entire function call can be assigned to a variable. True or False?
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.