+ 2
Why is the function of addoneto(x)
please explain https://code.sololearn.com/cRGs73Lju6Ah/?ref=app
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!
+ 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.