0% found this document useful (0 votes)
40 views2 pages

Passing by Value: This Method Copies The Actual Value of An Argument Into The Formal Parameter

Passing by value copies the actual value of an argument into a function's parameter, so changes to the parameter don't affect the argument. Passing by reference copies the reference, so changes to the parameter also affect the argument. In general, passing by value is faster but passing by reference is necessary when a function needs to modify the argument or for large data types.

Uploaded by

Ahmed Elsayed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Passing by Value: This Method Copies The Actual Value of An Argument Into The Formal Parameter

Passing by value copies the actual value of an argument into a function's parameter, so changes to the parameter don't affect the argument. Passing by reference copies the reference, so changes to the parameter also affect the argument. In general, passing by value is faster but passing by reference is necessary when a function needs to modify the argument or for large data types.

Uploaded by

Ahmed Elsayed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Summary

Passing by value: This method copies the actual value of an argument into the formal parameter
of the function. In this case, changes made to the parameter inside the function have no effect on
the argument.

Passing by reference: This method copies the reference of an argument into the formal
parameter. Inside the function, the reference is used to access the actual argument used in the
call. So, changes made to the parameter also affect the argument.
In general, passing by value is faster and more effective. Pass by reference when your function
needs to modify the argument, or when you need to pass a data type, that uses a lot of memory
and is expensive to copy.

In general, passing by value is faster and more effective. Pass by reference when your function needs to
modify the argument, or when you need to pass a data type, that uses a lot of memory and is expensive
to copy.

Explain of function

You might also like