Can any boby tell me the difference between call by reference and call by value? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 30

Can any boby tell me the difference between call by reference and call by value?

I am very much confused about it.

18th Feb 2017, 6:06 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
42 Answers
+ 57
Call by reference passes the actual variable's location in memory to the function. Therefore, the function acts upon the location in memory, changing the original variable. Pass by value passes a copy of the variable into the function. Thus, any changes made inside the function do not reflect upon the original variable.
18th Feb 2017, 9:15 PM
Varun Ramani
Varun Ramani - avatar
+ 10
Call By Value 1.copies the argument's actual value 2. original value is not get modified 3.parameter pass as a variable Call By Reference 1.copies the argument's address 2.original value is get modified. 3. parameter pass as a pointer
24th Feb 2017, 9:13 AM
Sumit Lokhande
Sumit Lokhande - avatar
+ 7
ok 👍
18th Feb 2017, 6:59 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 6
In-Call by value, we can send the vale of variable as a  parameter. In-Call by reference , we can send the memory address of  variable as a parameter
25th Feb 2017, 7:59 PM
Fatima Parveen
Fatima Parveen - avatar
+ 5
thankuu sir😊☺
18th Feb 2017, 6:35 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 4
thanx @varun
19th Feb 2017, 5:09 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 4
In 'call by value' values in the argument list are copied to formal parameters of subroutine and any changes made to to parameter base won't affect the arguments....but in case of 'call by reference' address of the argument is copied into the parameter.this means that changes made to the parameters affects the argument
23rd Feb 2017, 1:56 PM
Shaunak Pai Kane
Shaunak Pai Kane - avatar
+ 4
we don't have any bobies here sorry
25th Feb 2017, 7:08 PM
Alexander Slater
Alexander Slater - avatar
+ 4
does call by reference and call by address perform same functions?? because address locations are passed in both the cases....
26th Feb 2017, 4:32 PM
Shaunak Pai Kane
Shaunak Pai Kane - avatar
+ 3
thanku @moksh_makhija for ur help
18th Feb 2017, 6:46 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 3
but what this line state: cout<<x<<","<<y;
18th Feb 2017, 6:50 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 3
what will be the statement in java ?
18th Feb 2017, 6:54 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 3
can you please tell the examples in java
18th Feb 2017, 7:01 AM
Diptesh Mohanta
Diptesh Mohanta - avatar
+ 3
I try a short answer, which focuses on pragmatism: cbv is more secure as you play around with a new memory block and new variables. Depending on what you do in your function, you finally assign the result to the main program memory. Cbr is faster when the variable you want to work with is too costy regarding memory management. As you are working directly on the main function memory block, this should be handled with care but is much faster.
23rd Feb 2017, 8:36 AM
Senfman
Senfman - avatar
+ 3
in the call by reference method the function just works using the value of the variables and doesn't modify anything on the memory address where the variable exist But in call by value method operation is performed by the function on the passed memory address of the variables.... so any changes procured gets reflected on the actual value of the function....
27th Feb 2017, 1:03 AM
Yash Raghava
Yash Raghava - avatar
+ 2
in simple words call by value is simple calling by the the values i.e passing the values and calling th function. whereas in call by the reference instead of the values a reference variable is passed which holds the original values along with the function calling. call by reference does not show the values or inputs, it shows the reference whereas call by value shows the actual input or value to everyone.
22nd Feb 2017, 7:59 AM
Sahil Zainuddin
Sahil Zainuddin - avatar
+ 2
during call by values, any change in the formal parameter is not reflected back to actual parameter where as in call by reference method it is reflected back.. in call by reference the called function creates a new set of variables and copies the values of arguments
26th Feb 2017, 3:31 AM
Vathsala Msv
Vathsala Msv - avatar
+ 2
call by value passes the value of the variable like functionname(a) bt in call by ref we passes the address of the variable for eg functionname(&a)
26th Feb 2017, 8:23 AM
SUGANTHI M
SUGANTHI M - avatar
+ 2
Call by value means that our function is dealing with the values of passing variables only i.e, function is getting a copy of original values of variable while call by reference means function is dealing with original variable i.e, making change in that variable will affect our original values also.
26th Feb 2017, 8:32 AM
Shubham Kumar
Shubham Kumar - avatar
+ 2
Who are bobys?)
26th Feb 2017, 4:17 PM
Yaroslav
Yaroslav - avatar