+ 3

Please could someone tell me why value of "data" didnt change at first but when we say data=add(data); it changed??

https://code.sololearn.com/cdi1FEUv2of4/?ref=app

1st May 2018, 8:04 AM
RiGeL
RiGeL - avatar
2 Respostas
+ 2
The first time you just run the function add(data) and that does its work! This is so because you did not pass it by reference! Passing by value only add the input only to the value of x and input and not to the actual variable x. On the other hand, during the second try, you assign "the value of the sum of input to value of x" to the actual variable x! Note: But this does not work because you must be giving one input for the first one, but not providing the input for the second time. In the input dialog box, type input (any integer) input (the same number as above) And that shall do!
1st May 2018, 8:59 AM
Naveen Maurya
Naveen Maurya - avatar
+ 2
Naveen Maurya Thank you a bunch!
1st May 2018, 10:03 AM
RiGeL
RiGeL - avatar