

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Call by Value Call by Reference A way of passing arguments by copying the actual values into formal parameters of the function. A way of passing arguments by copying the addresses of the arguments to the formal parameters of the function. Does NOT affect the original values. DOES affect the original values. Values of the actual parameter are copied to the formal parameter of the function. Addresses of the actual parameters are copied to the formal parameter of the function. Calling function sends a copy of the data. Calling function sends the address of the data. The formal parameters are ordinary variables. The formal parameters are pointer variables. At most only one value can be sent back to the calling function. Several results can be sent back to the calling function. Actual parameters are NOT affected by Direct changes are made to the actual
Call by Value Call by Reference changes made within the function. parameter. Duplicate copy of original parameter is passed. Actual copy of original parameter is passed. No effects on original value after modifying. Original value gets affected if value is modified. Actual & formal parameters are created in different memory locations. Actual & formal parameters are created in the same memory location. Values of variables are passed by simple technique. Pointer variables are necessary to define to store address values of variables. Preferred when passing small values of data to a function. Preferred when passing large amounts of data to a function. Cannot alter the values of actual variables through function calls. Can alter the values of actual variables through function calls. Actual arguments remain safe — cannot be modified accidentally. Pointers of variables are required to store the address of values of variables. Default in many languages: C++, PHP, VB, Basic.Net, C#. Supports languages like Java. Syntax: function_name(variable_name1, variable_name2, ...) Syntax: function_name(&variable_name1, &variable_name2, ...)