+ 6

what is difference between pass by value and pass by reference

31st Jul 2016, 6:43 AM
abhijit bhusare
abhijit bhusare - avatar
4 Answers
+ 6
When you pass by value the function cannot change the argument, and when passing by reference can.
31st Jul 2016, 8:25 AM
Alexander T.
Alexander T. - avatar
+ 3
PASS BY VALUE: When a value is passed, the value is sent to the formal argument. Any change made in the formal argument is not made in the actual argument. PASS BY REFERENCE: When a value is passed, the address of the value is referenced to the formal argument. Any change made in the formal argument is referred to the actual argument.
31st Jul 2016, 2:35 PM
Chirag Dugar
Chirag Dugar - avatar
+ 2
in pass by value, we pass the arguments actual value through the variable name and in pass by reference, we pass the address of the variable.
1st Aug 2016, 7:24 PM
Manisha Bandagi
Manisha Bandagi - avatar
0
in pass by value we pass value of the actual argument to the formal argument and in pass by reference we pass the address of actual argument so when we make changes to the formal arguments they doesn't affect actual argument because a copy of actual arguments is send to the formal arguments in call by reference we send addresses so changes made to the formal arguments affects the actual arguments you can check by swapping program
8th Aug 2016, 9:00 PM
sachin tomar
sachin tomar - avatar