+ 2

Why is the function of addoneto(x)

please explain https://code.sololearn.com/cRGs73Lju6Ah/?ref=app

13th Oct 2017, 8:55 AM
Md. Junayed
Md. Junayed - avatar
2 Answers
+ 1
addOneTo gets a copy of x, not x itself. So changing num won't change x, and that's usually a good thing!
13th Oct 2017, 9:10 AM
Schindlabua
Schindlabua - avatar
+ 1
I think it is just showing you that x is used and passed into addoneto but not altered and returned back as x, that is why when printed x is 5 and not 6.
2nd Apr 2018, 9:30 AM
PARTH DHULLA
PARTH DHULLA - avatar